1 From 9bad339af848fc30bab4ea2759f022820f474e17 Mon Sep 17 00:00:00 2001
2 From: Neil Jerram <Neil.Jerram@metaswitch.com>
3 Date: Wed, 10 Jun 2015 22:16:35 +0100
4 Subject: [PATCH 110/113] Apply --bridge-interfaces to unsolicited router
8 src/radv.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
9 1 file changed, 84 insertions(+), 2 deletions(-)
11 diff --git a/src/radv.c b/src/radv.c
12 index 54784967df57..300c31c83c78 100644
15 @@ -40,9 +40,18 @@ struct search_param {
16 char name[IF_NAMESIZE+1];
21 + struct dhcp_bridge *bridge;
27 static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *dest);
28 static void send_ra_alias(time_t now, int iface, char *iface_name, struct in6_addr *dest,
30 +static int send_ra_to_aliases(int index, unsigned int type, char *mac, size_t maclen, void *parm);
31 static int add_prefixes(struct in6_addr *local, int prefix,
32 int scope, int if_index, int flags,
33 unsigned int preferred, unsigned int valid, void *vparam);
34 @@ -723,6 +732,7 @@ time_t periodic_ra(time_t now)
35 struct search_param param;
36 struct dhcp_context *context;
38 + struct alias_param aparam;
42 @@ -770,12 +780,84 @@ time_t periodic_ra(time_t now)
43 if (tmp->name && wildcard_match(tmp->name, param.name))
46 - send_ra(now, param.iface, param.name, NULL);
48 + send_ra(now, param.iface, param.name, NULL);
50 + /* Also send on all interfaces that are aliases of this
52 + for (aparam.bridge = daemon->bridges;
54 + aparam.bridge = aparam.bridge->next)
55 + if ((int)if_nametoindex(aparam.bridge->iface) == param.iface)
57 + /* Count the number of alias interfaces for this
58 + 'bridge', by calling iface_enumerate with
59 + send_ra_to_aliases and NULL alias_ifs. */
60 + aparam.iface = param.iface;
61 + aparam.alias_ifs = NULL;
62 + aparam.num_alias_ifs = 0;
63 + iface_enumerate(AF_LOCAL, &aparam, send_ra_to_aliases);
64 + my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s => %d alias(es)",
65 + param.name, daemon->addrbuff, aparam.num_alias_ifs);
67 + /* Allocate memory to store the alias interface
69 + aparam.alias_ifs = (int *)whine_malloc(aparam.num_alias_ifs *
71 + if (aparam.alias_ifs)
73 + /* Use iface_enumerate again to get the alias
74 + interface indices, then send on each of
76 + aparam.max_alias_ifs = aparam.num_alias_ifs;
77 + aparam.num_alias_ifs = 0;
78 + iface_enumerate(AF_LOCAL, &aparam, send_ra_to_aliases);
79 + for (; aparam.num_alias_ifs; aparam.num_alias_ifs--)
81 + my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s => i/f %d",
82 + param.name, daemon->addrbuff,
83 + aparam.alias_ifs[aparam.num_alias_ifs - 1]);
88 + aparam.alias_ifs[aparam.num_alias_ifs - 1]);
90 + free(aparam.alias_ifs);
93 + /* The source interface can only appear in at most
94 + one --bridge-interfaces. */
104 +static int send_ra_to_aliases(int index, unsigned int type, char *mac, size_t maclen, void *parm)
106 + struct alias_param *aparam = (struct alias_param *)parm;
107 + char ifrn_name[IFNAMSIZ];
108 + struct dhcp_bridge *alias;
114 + if (if_indextoname(index, ifrn_name))
115 + for (alias = aparam->bridge->alias; alias; alias = alias->next)
116 + if (wildcard_matchn(alias->iface, ifrn_name, IFNAMSIZ))
118 + if (aparam->alias_ifs && (aparam->num_alias_ifs < aparam->max_alias_ifs))
119 + aparam->alias_ifs[aparam->num_alias_ifs] = index;
120 + aparam->num_alias_ifs++;
126 static int iface_search(struct in6_addr *local, int prefix,
127 int scope, int if_index, int flags,
128 int preferred, int valid, void *vparam)