@@ -159,6 +159,7 @@ static int mcast6_addr_del(const struct iface *iface, const struct rte_ipv6_addr
159159
160160static int
161161iface6_addr_add (const struct iface * iface , const struct rte_ipv6_addr * ip , uint8_t prefixlen ) {
162+ struct rte_ipv6_addr solicited_node ;
162163 struct hoplist * addrs ;
163164 struct nexthop * nh ;
164165 int ret ;
@@ -193,6 +194,15 @@ iface6_addr_add(const struct iface *iface, const struct rte_ipv6_addr *ip, uint8
193194 if ((nh = nexthop_new (& base )) == NULL )
194195 return errno_set (- errno );
195196
197+ // join the solicited node multicast group
198+ rte_ipv6_solnode_from_addr (& solicited_node , ip );
199+ if (mcast6_addr_add (iface , & solicited_node ) < 0 ) {
200+ if (errno != EOPNOTSUPP && errno != EEXIST ) {
201+ nexthop_decref (nh );
202+ return errno_set (errno );
203+ }
204+ }
205+
196206 ret = rib6_insert (iface -> vrf_id , iface -> id , ip , nh -> prefixlen , GR_NH_ORIGIN_LINK , nh );
197207 if (ret < 0 )
198208 return errno_set (- ret );
@@ -205,7 +215,6 @@ iface6_addr_add(const struct iface *iface, const struct rte_ipv6_addr *ip, uint8
205215
206216static struct api_out addr6_add (const void * request , struct api_ctx * ) {
207217 const struct gr_ip6_addr_add_req * req = request ;
208- struct rte_ipv6_addr solicited_node ;
209218 struct iface * iface ;
210219 int ret ;
211220
@@ -217,13 +226,6 @@ static struct api_out addr6_add(const void *request, struct api_ctx *) {
217226 if (ret != - EEXIST || !req -> exist_ok )
218227 return api_out (- ret , 0 , NULL );
219228
220- // join the solicited node multicast group
221- rte_ipv6_solnode_from_addr (& solicited_node , & req -> addr .addr .ip );
222- if (mcast6_addr_add (iface , & solicited_node ) < 0 ) {
223- if (errno != EOPNOTSUPP && errno != EEXIST )
224- return api_out (errno , 0 , NULL );
225- }
226-
227229 return api_out (0 , 0 , NULL );
228230}
229231
@@ -302,8 +304,8 @@ static const struct rte_ipv6_addr well_known_mcast_addrs[] = {
302304};
303305
304306static void ip6_iface_event_handler (uint32_t event , const void * obj ) {
305- struct rte_ipv6_addr link_local , solicited_node ;
306307 const struct iface * iface = obj ;
308+ struct rte_ipv6_addr link_local ;
307309 struct rte_ether_addr mac ;
308310 struct nexthop * nh ;
309311 unsigned i ;
@@ -316,10 +318,6 @@ static void ip6_iface_event_handler(uint32_t event, const void *obj) {
316318 rte_ipv6_llocal_from_ethernet (& link_local , & mac );
317319 if (iface6_addr_add (iface , & link_local , 64 ) < 0 )
318320 errno_log (errno , "iface_addr_add" );
319-
320- rte_ipv6_solnode_from_addr (& solicited_node , & link_local );
321- if (mcast6_addr_add (iface , & solicited_node ) < 0 )
322- LOG (INFO , "%s: mcast_addr_add: %s" , iface -> name , strerror (errno ));
323321 }
324322 for (i = 0 ; i < ARRAY_DIM (well_known_mcast_addrs ); i ++ ) {
325323 if (mcast6_addr_add (iface , & well_known_mcast_addrs [i ]) < 0 )
0 commit comments