1 From ba4fc0f99619014438621ccd2bc473657ab4c51c Mon Sep 17 00:00:00 2001
2 From: Neil Jerram <Neil.Jerram@metaswitch.com>
3 Date: Wed, 10 Jun 2015 22:14:49 +0100
4 Subject: [PATCH 109/113] Upply --bridge-interface aliasing to solicited router
8 src/radv.c | 45 ++++++++++++++++++++++++++++++++++++++++-----
9 1 file changed, 40 insertions(+), 5 deletions(-)
11 diff --git a/src/radv.c b/src/radv.c
12 index ec22464b78b9..54784967df57 100644
15 @@ -41,6 +41,8 @@ struct search_param {
18 static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *dest);
19 +static void send_ra_alias(time_t now, int iface, char *iface_name, struct in6_addr *dest,
21 static int add_prefixes(struct in6_addr *local, int prefix,
22 int scope, int if_index, int flags,
23 unsigned int preferred, unsigned int valid, void *vparam);
24 @@ -181,6 +183,7 @@ void icmp6_packet(time_t now)
25 else if (packet[0] == ND_ROUTER_SOLICIT)
28 + struct dhcp_bridge *bridge, *alias;
30 /* look for link-layer address option for logging */
31 if (sz >= 16 && packet[8] == ICMP6_OPT_SOURCE_MAC && (packet[9] * 8) + 8 <= sz)
32 @@ -191,12 +194,37 @@ void icmp6_packet(time_t now)
34 if (!option_bool(OPT_QUIET_RA))
35 my_syslog(MS_DHCP | LOG_INFO, "RTR-SOLICIT(%s) %s", interface, mac);
36 - /* source address may not be valid in solicit request. */
37 - send_ra(now, if_index, interface, !IN6_IS_ADDR_UNSPECIFIED(&from.sin6_addr) ? &from.sin6_addr : NULL);
39 + /* If the incoming interface is an alias of some other one (as
40 + specified by the --bridge-interfaces option), send an RA
41 + using the context of the aliased interface. */
42 + for (bridge = daemon->bridges; bridge; bridge = bridge->next)
44 + int bridge_index = if_nametoindex(bridge->iface);
47 + for (alias = bridge->alias; alias; alias = alias->next)
48 + if (wildcard_matchn(alias->iface, interface, IF_NAMESIZE))
50 + /* Send an RA on if_index with information from
52 + send_ra_alias(now, bridge_index, bridge->iface, NULL, if_index);
60 + /* If the incoming interface wasn't an alias, send an RA using
61 + the context of the incoming interface. */
63 + /* source address may not be valid in solicit request. */
64 + send_ra(now, if_index, interface, !IN6_IS_ADDR_UNSPECIFIED(&from.sin6_addr) ? &from.sin6_addr : NULL);
68 -static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *dest)
69 +static void send_ra_alias(time_t now, int iface, char *iface_name, struct in6_addr *dest, int send_iface)
73 @@ -370,7 +398,7 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
77 - iface_enumerate(AF_LOCAL, &iface, add_lla);
78 + iface_enumerate(AF_LOCAL, &send_iface, add_lla);
80 /* RDNSS, RFC 6106, use relevant DHCP6 options */
81 (void)option_filter(parm.tags, NULL, daemon->dhcp_opts6);
82 @@ -478,7 +506,7 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
85 inet_pton(AF_INET6, ALL_NODES, &addr.sin6_addr);
86 - setsockopt(daemon->icmp6fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, &iface, sizeof(iface));
87 + setsockopt(daemon->icmp6fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, &send_iface, sizeof(send_iface));
90 while (retry_send(sendto(daemon->icmp6fd, daemon->outpacket.iov_base,
91 @@ -487,6 +515,13 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
95 +static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *dest)
97 + /* Send an RA on the same interface that the RA content is based
99 + send_ra_alias(now, iface, iface_name, dest, iface);
102 static int add_prefixes(struct in6_addr *local, int prefix,
103 int scope, int if_index, int flags,
104 unsigned int preferred, unsigned int valid, void *vparam)