treewide: reflect managed mode is related to RA
authorHans Dedecker <dedeckeh@gmail.com>
Tue, 1 Aug 2017 21:14:33 +0000 (23:14 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 2 Aug 2017 08:09:33 +0000 (10:09 +0200)
Improve code readability by renaming managed into ra_managed and
define the according ra_managed flags.
This will help to better understand the ra_managed logic as defined
in the README file.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/config.c
src/dhcpv6-ia.c
src/odhcpd.h
src/router.c

index e6f23828d4538bf5725728e8d225858b768e1e9b..8670efc316d943a74fe26b23e5422d8b94f44b06 100644 (file)
@@ -205,7 +205,7 @@ static struct interface* get_interface(const char *name)
 
 static void set_interface_defaults(struct interface *iface)
 {
-       iface->managed = 1;
+       iface->ra_managed = RA_MANAGED_MFLAG;
        iface->learn_routes = 1;
        iface->dhcpv4_leasetime = 43200;
        iface->ra_maxinterval = 600;
@@ -621,7 +621,7 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                iface->default_router = blobmsg_get_u32(c);
 
        if ((c = tb[IFACE_ATTR_RA_MANAGEMENT]))
-               iface->managed = blobmsg_get_u32(c);
+               iface->ra_managed = blobmsg_get_u32(c);
 
        if ((c = tb[IFACE_ATTR_RA_REACHABLETIME])) {
                uint32_t ra_reachabletime = blobmsg_get_u32(c);
index 502373fd9904c8c6e4b362c7332c6c3cbc45152b..8bf42c8876c4fa454823931fbb6f658647194bd3 100644 (file)
@@ -36,7 +36,7 @@
 #include <libubox/usock.h>
 
 #define ADDR_ENTRY_VALID_IA_ADDR(iface, i, m, addrs) \
-    ((iface)->managed == RELAYD_MANAGED_NO_AFLAG || (i) == (m) || \
+    ((iface)->ra_managed == RA_MANAGED_NO_AFLAG || (i) == (m) || \
      (addrs)[(i)].prefix > 64)
 
 static void free_dhcpv6_assignment(struct dhcpv6_assignment *c);
@@ -657,7 +657,8 @@ void dhcpv6_ia_preupdate(struct interface *iface)
                        &iface->ia_assignments, struct dhcpv6_assignment, head);
 
        list_for_each_entry(c, &iface->ia_assignments, head)
-               if (c != border && !iface->managed && (c->flags & OAF_BOUND))
+               if (c != border && iface->ra_managed == RA_MANAGED_NO_MFLAG
+                               && (c->flags & OAF_BOUND))
                        apply_lease(iface, c, false);
 }
 
index 28eb88e00a5c7972ae43317b9ca3a3e4b70b7f0b..10f0edbe80bae725f98dced345f411097910bc9a 100644 (file)
@@ -160,7 +160,7 @@ struct interface {
        // RA
        int learn_routes;
        int default_router;
-       int managed;
+       int ra_managed;
        int route_preference;
        int ra_maxinterval;
        int ra_mininterval;
@@ -196,8 +196,9 @@ struct interface {
 
 extern struct list_head interfaces;
 
-#define RELAYD_MANAGED_MFLAG   1
-#define RELAYD_MANAGED_NO_AFLAG        2
+#define RA_MANAGED_NO_MFLAG    0
+#define RA_MANAGED_MFLAG       1
+#define RA_MANAGED_NO_AFLAG    2
 
 
 // Exported main functions
index 19702a2d08f3af29e23a74e508dcb2e777fcebeb..cb2afc962b9f7aee14ab275b477b0ed7a799be1f 100644 (file)
@@ -298,7 +298,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
        if (iface->dhcpv6)
                adv.h.nd_ra_flags_reserved = ND_RA_FLAG_OTHER;
 
-       if (iface->managed >= RELAYD_MANAGED_MFLAG)
+       if (iface->ra_managed >= RA_MANAGED_MFLAG)
                adv.h.nd_ra_flags_reserved |= ND_RA_FLAG_MANAGED;
 
        if (iface->route_preference < 0)
@@ -408,7 +408,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                p->nd_opt_pi_flags_reserved = 0;
                if (!iface->ra_not_onlink)
                        p->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_ONLINK;
-               if (iface->managed < RELAYD_MANAGED_NO_AFLAG && addr->prefix <= 64)
+               if (iface->ra_managed < RA_MANAGED_NO_AFLAG && addr->prefix <= 64)
                        p->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_AUTO;
                if (iface->ra_advrouter)
                        p->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_RADDR;