Send connman mailing list submissions to
        connman@lists.01.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        connman-requ...@lists.01.org

You can reach the person managing the list at
        connman-ow...@lists.01.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."


Today's Topics:

   1. Re: [PATCH 13/27] acd: add callback function pointers
      (Daniel Wagner)
   2. Re: [PATCH 15/27] acd: add acd_defend_timeout and
      acd_announce_timeout (Daniel Wagner)
   3. Re: [PATCH 14/27] acd: add acdhost_start and acdhost_stop
      (Daniel Wagner)
   4. Re: [PATCH 16/27] acd: add handling of received arp packets
      (Daniel Wagner)
   5. Re: [PATCH 17/27] acd: add callback registration (Daniel Wagner)
   6. Re: [PATCH 18/27] network: init and start of acd (Daniel Wagner)
   7. Re: [PATCH 19/27] network: add content of acd callback
      functions (Daniel Wagner)
   8. Re: [PATCH 20/27] network: add ipv4ll as fallback for acd
      (Daniel Wagner)


----------------------------------------------------------------------

Message: 1
Date: Mon, 16 Apr 2018 17:00:48 +0200
From: Daniel Wagner <w...@monom.org>
To: Christian Spielberger <christian.spielber...@gmail.com>
Cc: connman@lists.01.org
Subject: Re: [PATCH 13/27] acd: add callback function pointers
Message-ID: <8284b67b-b7de-38ae-06d7-85198c810...@monom.org>
Content-Type: text/plain; charset=utf-8

Hi Christian,

On 04/11/2018 04:00 PM, Christian Spielberger wrote:
> Adds the callback functions for higher level address conflict handling.
> 
> ipv4_available_cb will be called if there was no address conflict detected.
> 
> ipv4_lost_cb will be called if another host is using our IPv4 address and
>      defending was not successfull.
> 
> ipv4_conflict_cb will be called if ACD detected a conflict during probing and
>      there had been less than MAX_CONFLICTS conflicts.
> 
> ipv4_max_conflicts_cb will be called if ACD detected a conflict during probing
>      and there had been at least MAX_CONFLICTS conflicts.
> ---
>   include/acd.h |  3 +++
>   src/acd.c     | 14 ++++++++++++++
>   2 files changed, 17 insertions(+)
> 
> diff --git a/include/acd.h b/include/acd.h
> index 08f9ec9..dbef0b3 100644
> --- a/include/acd.h
> +++ b/include/acd.h
> @@ -24,6 +24,7 @@
>   #define __CONNMAN_ACD_H
>   
>   #include <stdint.h>
> +#include <glib.h>
>   
>   #ifdef __cplusplus
>   extern "C" {
> @@ -35,6 +36,8 @@ typedef struct _acd_host acd_host;
>   
>   acd_host *acdhost_new(int ifindex);
>   
> +typedef void (*ACDHostEventFunc) (acd_host *acd, gpointer user_data);
> +

The typedef name should be something like:

connman.h:typedef void (* authentication_cb_t) (struct connman_service *service,
connman.h:typedef void (* browser_authentication_cb_t) (struct connman_service 
*service,
connman.h:typedef void (* peer_wps_cb_t) (struct connman_peer *peer, bool 
choice_done,
connman.h:typedef void (*__connman_inet_rs_cb_t) (struct nd_router_advert 
*reply,
connman.h:typedef void (*__connman_inet_ns_cb_t) (struct nd_neighbor_advert 
*reply,
connman.h:typedef void (*__connman_inet_recv_rs_cb_t) (struct nd_router_solicit 
*reply,
connman.h:typedef void (*connman_inet_addr_cb_t) (const char *src_address, int 
index,
connman.h:typedef void (*__connman_inet_rtnl_cb_t) (struct nlmsghdr *answer,
connman.h:typedef void (* dhcpv6_cb) (struct connman_network *network,
connman.h:typedef void (* dhcp_cb) (struct connman_ipconfig *ipconfig,
connman.h:typedef void (*__connman_ntp_cb_t) (bool success, void *user_data);
connman.h:typedef void (* service_iterate_cb) (struct connman_service *service,
connman.h:typedef void (*connman_iptables_iterate_chains_cb_t) (const char 
*chain_name,
connman.h:typedef void (*ippool_collision_cb_t) (struct connman_ippool *pool,
connman.h:typedef int (* connman_nfacct_flush_cb_t) (unsigned int error, void 
*user_data);
connman.h:typedef void (* connman_nfacct_enable_cb_t) (unsigned int error,

As you can see it is not completely consistent but there is no
CammelCasing. Yes, the gdhcp directory doesn't follow this rule. Did
I already mention I'd like to replace this code with systemd's dhcp
implementation? :)

Thanks,
Daniel


------------------------------

Message: 2
Date: Mon, 16 Apr 2018 17:02:58 +0200
From: Daniel Wagner <w...@monom.org>
To: Christian Spielberger <christian.spielber...@gmail.com>
Cc: connman@lists.01.org
Subject: Re: [PATCH 15/27] acd: add acd_defend_timeout and
        acd_announce_timeout
Message-ID: <78a0283f-a58e-edf6-e56b-c4248b574...@monom.org>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi Christian,

On 04/11/2018 04:00 PM, Christian Spielberger wrote:
> Adds the content of acd_defend_timeout which switches from state DEFEND back
> to MONITOR. Also adds content of acd_announce_timeout which sends repeated
> announce packets until ANNOUNCE_NUM is reached, then switches back to state
> MONITOR.
> ---
>   src/acd.c | 38 ++++++++++++++++++++++++++++++++++++++
>   1 file changed, 38 insertions(+)
> 
> diff --git a/src/acd.c b/src/acd.c
> index fcc955c..76dbc77 100644
> --- a/src/acd.c
> +++ b/src/acd.c
> @@ -27,6 +27,9 @@
>   #include <unistd.h>
>   #include <stdarg.h>
>   #include <stdio.h>
> +#include <netinet/if_ether.h>
> +#include <net/if_arp.h>
> +#include <string.h>
>   
>   typedef enum _acd_state {
>       ACD_PROBE,
> @@ -35,6 +38,13 @@ typedef enum _acd_state {
>       ACD_DEFEND,
>   } ACDState;
>   
> +static const char* acd_state_texts[] = {
> +     "PROBE",
> +     "ANNOUNCE",
> +     "MONITOR",
> +     "DEFEND"
> +};
> +

You are not using acd_state_texts in this patch. The compile will 
probably complain here.

Thanks,
Daniel


------------------------------

Message: 3
Date: Mon, 16 Apr 2018 17:03:34 +0200
From: Daniel Wagner <w...@monom.org>
To: Christian Spielberger <christian.spielber...@gmail.com>
Cc: connman@lists.01.org
Subject: Re: [PATCH 14/27] acd: add acdhost_start and acdhost_stop
Message-ID: <095904eb-50b3-552b-dc62-4c3e6f0ab...@monom.org>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi Christian,

On 04/11/2018 04:00 PM, Christian Spielberger wrote:
> Adds functions for starting and stopping ACD.
> ---
>   include/acd.h |  2 ++
>   src/acd.c     | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   src/network.c |  3 +++
>   3 files changed, 59 insertions(+)
> 
> diff --git a/include/acd.h b/include/acd.h
> index dbef0b3..24b4707 100644
> --- a/include/acd.h
> +++ b/include/acd.h
> @@ -35,6 +35,8 @@ struct _acd_host;
>   typedef struct _acd_host acd_host;
>   
>   acd_host *acdhost_new(int ifindex);
> +int acdhost_start(acd_host *acd, uint32_t ip);
> +void acdhost_stop(acd_host *acd);

acd_host_start()
acd_host_stop()

Thanks,
Daniel


------------------------------

Message: 4
Date: Mon, 16 Apr 2018 17:09:11 +0200
From: Daniel Wagner <w...@monom.org>
To: Christian Spielberger <christian.spielber...@gmail.com>
Cc: connman@lists.01.org
Subject: Re: [PATCH 16/27] acd: add handling of received arp packets
Message-ID: <4e152dc0-bcb4-c953-a5af-70130b230...@monom.org>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi Christian,

On 04/11/2018 04:00 PM, Christian Spielberger wrote:
> Adds implementation of acd_recv_arp_packet. This is the main logic for ACD. As
> long as ACD is activated received ARP packets are checked for potential 
> address
> conflicts.
> ---
>   src/acd.c | 82 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 82 insertions(+)
> 
> diff --git a/src/acd.c b/src/acd.c
> index 76dbc77..c796f2f 100644
> --- a/src/acd.c
> +++ b/src/acd.c
> @@ -371,4 +371,86 @@ static gboolean acd_announce_timeout(gpointer acd_data)
>   }
>   
>   static int acd_recv_arp_packet(acd_host *acd) {
> +     ssize_t cnt;
> +     struct ether_arp arp;
> +     uint32_t ip_n; /* network byte order */
> +     struct in_addr addr;
> +     int source_conflict;
> +     int target_conflict;
> +     bool probe;
> +     char* confltxt;
> +     uint8_t* mac;
> +     uint8_t* omac;
> +
> +     memset(&arp, 0, sizeof(arp));
> +     cnt = read(acd->listener_sockfd, &arp, sizeof(arp));
> +     if (cnt != sizeof(arp))
> +             return -EINVAL;
> +
> +     if (arp.arp_op != htons(ARPOP_REPLY) &&
> +                     arp.arp_op != htons(ARPOP_REQUEST))
> +             return -EINVAL;
> +
> +     if (memcmp(arp.arp_sha, acd->mac_address, ETH_ALEN) == 0)
> +             return 0;
> +
> +     ip_n = htonl(acd->requested_ip);
> +     source_conflict = !memcmp(arp.arp_spa, &ip_n, sizeof(uint32_t));
> +     probe = !memcmp(arp.arp_spa, "\0\0\0\0", sizeof(uint32_t));
> +     target_conflict = probe &&
> +             !memcmp(arp.arp_tpa, &ip_n, sizeof(uint32_t));
> +
> +     if (!source_conflict && !target_conflict)
> +             return 0;
> +
> +     acd->conflicts++;
> +
> +     confltxt = target_conflict ? "target" : "source";
> +
> +     addr.s_addr = ip_n;
> +     debug(acd, "IPv4 %d %s conflicts detected for address %s. "
> +                     "State=%s", acd->conflicts, confltxt, inet_ntoa(addr),
> +                     acd_state_texts[acd->state]);
> +     mac = acd->mac_address;
> +     omac = arp.arp_sha;
> +     debug(acd, "Our MAC: %02x:%02x:%02x:%02x:%02x:%02x"
> +                        " other MAC: %02x:%02x:%02x:%02x:%02x:%02x",
> +                     mac[0], mac[1], mac[2],mac[3], mac[4], mac[5],
> +                     omac[0], omac[1], omac[2],omac[3], omac[4], omac[5]);
> +
> +     if (acd->state == ACD_MONITOR) {
> +             if (!source_conflict)
> +                     return 0;
> +
> +             acd->state = ACD_DEFEND;
> +             debug(acd, "DEFEND mode conflicts: %d", acd->conflicts);
> +             /* Try to defend with a single announce. */
> +             send_announce_packet(acd);
> +             return 0;
> +     } else if (acd->state == ACD_DEFEND) {
> +             if (!source_conflict)
> +                     return 0;
> +
> +             debug(acd, "LOST IPv4 address %s", inet_ntoa(addr));
> +             if (acd->ipv4_lost_cb)
> +                     acd->ipv4_lost_cb(acd, acd->ipv4_lost_data);
> +             return 0;
> +     }
> +
> +     if (acd->conflicts < MAX_CONFLICTS) {
> +             acdhost_stop(acd);
> +
> +             /* we need a new request_ip */
> +             if (acd->ipv4_conflict_cb)
> +                     acd->ipv4_conflict_cb(acd, acd->ipv4_conflict_data);
> +     } else {
> +             acdhost_stop(acd);
> +
> +             /* Here we got a lot of conflicts, RFC3927 and RFC5227 state 
> that we
> +              * have to wait RATE_LIMIT_INTERVAL before retrying. */

See coding-style.txt M2: Multiple line comment


------------------------------

Message: 5
Date: Mon, 16 Apr 2018 17:10:27 +0200
From: Daniel Wagner <w...@monom.org>
To: Christian Spielberger <christian.spielber...@gmail.com>
Cc: connman@lists.01.org
Subject: Re: [PATCH 17/27] acd: add callback registration
Message-ID: <93ec657b-616a-b960-3c03-695f9b157...@monom.org>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi Christian,

On 04/11/2018 04:00 PM, Christian Spielberger wrote:
> Adds function acdhost_register_event for registration of higher level address
> conflict callback functions.
> ---
>   include/acd.h | 12 ++++++++++++
>   src/acd.c     | 29 +++++++++++++++++++++++++++++
>   2 files changed, 41 insertions(+)
> 
> diff --git a/include/acd.h b/include/acd.h
> index 24b4707..dc7e570 100644
> --- a/include/acd.h
> +++ b/include/acd.h
> @@ -40,6 +40,18 @@ void acdhost_stop(acd_host *acd);
>   
>   typedef void (*ACDHostEventFunc) (acd_host *acd, gpointer user_data);
>   
> +typedef enum {
> +     ACDHOST_EVENT_IPV4_AVAILABLE,
> +     ACDHOST_EVENT_IPV4_LOST,
> +     ACDHOST_EVENT_IPV4_CONFLICT,
> +     ACDHOST_EVENT_IPV4_MAXCONFLICT,
> +} ACDHostEvent;

No typedef, codying-style.txt M11: Naming of enums

Thanks,
Daniel


------------------------------

Message: 6
Date: Mon, 16 Apr 2018 17:11:38 +0200
From: Daniel Wagner <w...@monom.org>
To: Christian Spielberger <christian.spielber...@gmail.com>
Cc: connman@lists.01.org
Subject: Re: [PATCH 18/27] network: init and start of acd
Message-ID: <38980486-b619-964e-66e7-3af87a357...@monom.org>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi Christian,

On 04/11/2018 04:00 PM, Christian Spielberger wrote:
> Adds empty higher level ACD callback functions. Also adds content of function
> start_acd which is allocation of ACD structure, registration of callback
> functions and invoke ACD with a pre-defined IPv4 address.
> ---
>   src/network.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 53 insertions(+)
> 
> diff --git a/src/network.c b/src/network.c
> index acf4179..e3207da 100644
> --- a/src/network.c
> +++ b/src/network.c
> @@ -27,6 +27,7 @@
>   #include <string.h>
>   
>   #include <connman/acd.h>
> +#include "src/shared/arp.h"

After '#include "connman.h"

>   #include "connman.h"
>   
>   /*

Thanks,
Daniel


------------------------------

Message: 7
Date: Mon, 16 Apr 2018 17:18:18 +0200
From: Daniel Wagner <w...@monom.org>
To: Christian Spielberger <christian.spielber...@gmail.com>
Cc: connman@lists.01.org
Subject: Re: [PATCH 19/27] network: add content of acd callback
        functions
Message-ID: <2ef9777a-841a-d606-55db-d121ed809...@monom.org>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi Christian,

On 04/11/2018 04:00 PM, Christian Spielberger wrote:
> Adds content for acdhost_ipv4_available and acdhost_ipv4_lost which is 
> basically
> applying (adding) and removing an IPv4 address to ipconfig.
> ---

> +     method = __connman_ipconfig_get_method(ipconfig_ipv4);
> +     if (method == CONNMAN_IPCONFIG_METHOD_DHCP) {
> +             /* We have one more chance for DHCP. If this fails
> +              * acdhost_ipv4_conflict will be called. */

Multiline comment style is not correct.

Thanks,
Daniel


------------------------------

Message: 8
Date: Mon, 16 Apr 2018 17:21:52 +0200
From: Daniel Wagner <w...@monom.org>
To: Christian Spielberger <christian.spielber...@gmail.com>
Cc: connman@lists.01.org
Subject: Re: [PATCH 20/27] network: add ipv4ll as fallback for acd
Message-ID: <0f57194d-f11a-730c-4cc8-5e517a8e1...@monom.org>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi Christian,

On 04/11/2018 04:00 PM, Christian Spielberger wrote:
> When an address conflict is detected for the static IPv4 configuration a free
> IPv4LL address has to be found. This patch adds functions start_ipv4ll for
> starting the IPv4LL process, start_ipv4ll_ontimeout for a delayed start of
> IPv4LL and remove_ipv4ll_timeout for stopping the delayed start.
> 
> For IPv4LL process again we use the new ACD functions.
> ---
>   src/network.c | 71 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 71 insertions(+)
> 
> diff --git a/src/network.c b/src/network.c
> index 5b79a2a..a7d6af4 100644
> --- a/src/network.c
> +++ b/src/network.c
> @@ -70,6 +70,7 @@ struct connman_network {
>       int router_solicit_count;
>       int router_solicit_refresh_count;
>       acd_host *acdhost;
> +     guint ipv4ll_timeout;
>   
>       struct connman_network_driver *driver;
>       void *driver_data;
> @@ -159,6 +160,14 @@ static void set_configuration(struct connman_network 
> *network,
>   
>   static int start_acd(struct connman_network *network);
>   
> +static void remove_ipv4ll_timeout(struct connman_network *network)
> +{
> +     if (network->ipv4ll_timeout > 0) {
> +             g_source_remove(network->ipv4ll_timeout);
> +             network->ipv4ll_timeout = 0;
> +     }
> +}
> +
>   static void acdhost_ipv4_available(acd_host *acd, gpointer user_data)
>   {
>       struct connman_network *network = user_data;
> @@ -196,6 +205,51 @@ err:
>                               CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
>   }
>   
> +static int start_ipv4ll(struct connman_network *network)
> +{
> +     struct connman_service *service;
> +     struct connman_ipconfig *ipconfig_ipv4;
> +     struct in_addr addr;
> +     char *address;
> +
> +     service = connman_service_lookup_from_network(network);
> +     if (!service)
> +             return -EINVAL;
> +
> +     ipconfig_ipv4 = __connman_service_get_ip4config(service);
> +     if (!ipconfig_ipv4) {
> +             connman_error("Service has no IPv4 configuration");
> +             return -EINVAL;
> +     }
> +
> +     /* Apply random IPv4 address. */
> +     addr.s_addr = htonl(random_ip());
> +     address = inet_ntoa(addr);
> +     if (!address) {
> +             connman_error("Could not convert IPv4LL random address %u",
> +                             addr.s_addr);
> +             return -EINVAL;
> +     }
> +     __connman_ipconfig_set_local(ipconfig_ipv4, address);
> +
> +     connman_info("Probing IPv4LL address %s", address);
> +     return start_acd(network);
> +}
> +
> +static gboolean start_ipv4ll_ontimeout(gpointer data)
> +{
> +     struct connman_network *network = data;
> +
> +     if (!network)
> +             return FALSE;
> +
> +     /* Start IPv4LL ACD. */
> +     if (start_ipv4ll(network) < 0)
> +             connman_error("Could not start IPv4LL. No address will be 
> assigned");

start_ipv4ll already prints an error message if something goes wrong. Is 
there any additional value in having another error message printed?

> +
> +     return FALSE;
> +}
> +
>   static void acdhost_ipv4_lost(acd_host *acd, gpointer user_data)
>   {
>       struct connman_network *network = user_data;
> @@ -232,6 +286,9 @@ static void acdhost_ipv4_lost(acd_host *acd, gpointer 
> user_data)
>                       __connman_network_enable_ipconfig(network, 
> ipconfig_ipv4);
>       } else {
>               /* Start IPv4LL ACD. */
> +             if (start_ipv4ll(network) < 0)
> +                     connman_error("Could not start IPv4LL. "
> +                                     "No address will be assigned");

same here.

>       }
>   }
>   
> @@ -240,15 +297,25 @@ static void acdhost_ipv4_conflict(acd_host *acd, 
> gpointer user_data)
>       struct connman_network *network = user_data;
>   
>       /* Start IPv4LL ACD. */
> +     if (start_ipv4ll(network) < 0)
> +             connman_error("Could not start IPv4LL. "
> +                             "No address will be assigned");

and here.

Thanks,
Daniel


------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
connman@lists.01.org
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 30, Issue 16
***************************************

Reply via email to