From f4d38e0a853e933a4da54fde8ec2711b5dc5b741 Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Tue, 1 Aug 2017 23:14:33 +0200 Subject: treewide: reflect managed mode is related to RA 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 --- src/config.c | 4 ++-- src/dhcpv6-ia.c | 5 +++-- src/odhcpd.h | 7 ++++--- src/router.c | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/config.c b/src/config.c index e6f2382..8670efc 100644 --- a/src/config.c +++ b/src/config.c @@ -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); diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index 502373f..8bf42c8 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -36,7 +36,7 @@ #include #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); } diff --git a/src/odhcpd.h b/src/odhcpd.h index 28eb88e..10f0edb 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -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 diff --git a/src/router.c b/src/router.c index 19702a2..cb2afc9 100644 --- a/src/router.c +++ b/src/router.c @@ -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; -- cgit v1.2.3