]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/dnsmasq/0109-Upply-bridge-interface-aliasing-to-solicited-router-.patch
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
[ipfire-2.x.git] / src / patches / dnsmasq / 0109-Upply-bridge-interface-aliasing-to-solicited-router-.patch
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
5 advertisements.
6
7 ---
8 src/radv.c | 45 ++++++++++++++++++++++++++++++++++++++++-----
9 1 file changed, 40 insertions(+), 5 deletions(-)
10
11 diff --git a/src/radv.c b/src/radv.c
12 index ec22464b78b9..54784967df57 100644
13 --- a/src/radv.c
14 +++ b/src/radv.c
15 @@ -41,6 +41,8 @@ struct search_param {
16 };
17
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,
20 + int send_iface);
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)
26 {
27 char *mac = "";
28 + struct dhcp_bridge *bridge, *alias;
29
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)
33
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);
38 +
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)
43 + {
44 + int bridge_index = if_nametoindex(bridge->iface);
45 + if (bridge_index)
46 + {
47 + for (alias = bridge->alias; alias; alias = alias->next)
48 + if (wildcard_matchn(alias->iface, interface, IF_NAMESIZE))
49 + {
50 + /* Send an RA on if_index with information from
51 + bridge_index. */
52 + send_ra_alias(now, bridge_index, bridge->iface, NULL, if_index);
53 + break;
54 + }
55 + if (alias)
56 + break;
57 + }
58 + }
59 +
60 + /* If the incoming interface wasn't an alias, send an RA using
61 + the context of the incoming interface. */
62 + if (!bridge)
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);
65 }
66 }
67
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)
70 {
71 struct ra_packet *ra;
72 struct ra_param parm;
73 @@ -370,7 +398,7 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
74 }
75 #endif
76
77 - iface_enumerate(AF_LOCAL, &iface, add_lla);
78 + iface_enumerate(AF_LOCAL, &send_iface, add_lla);
79
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
83 else
84 {
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));
88 }
89
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
92
93 }
94
95 +static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *dest)
96 +{
97 + /* Send an RA on the same interface that the RA content is based
98 + on. */
99 + send_ra_alias(now, iface, iface_name, dest, iface);
100 +}
101 +
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)
105 --
106 2.1.0
107