]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Address linked list routine. | |
3 | * Copyright (C) 1997, 98 Kunihiro Ishiguro | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License along | |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | */ | |
21 | ||
22 | #include <zebra.h> | |
23 | ||
24 | #include "prefix.h" | |
25 | #include "linklist.h" | |
26 | #include "if.h" | |
27 | #include "table.h" | |
28 | #include "rib.h" | |
29 | #include "table.h" | |
30 | #include "log.h" | |
31 | #include "memory.h" | |
32 | #include "zebra_memory.h" | |
33 | ||
34 | #include "vty.h" | |
35 | #include "zebra/debug.h" | |
36 | #include "zebra/zserv.h" | |
37 | #include "zebra/redistribute.h" | |
38 | #include "zebra/interface.h" | |
39 | #include "zebra/connected.h" | |
40 | #include "zebra/rtadv.h" | |
41 | #include "zebra/zebra_mpls.h" | |
42 | #include "zebra/debug.h" | |
43 | #include "zebra/zebra_errors.h" | |
44 | ||
45 | /* communicate the withdrawal of a connected address */ | |
46 | static void connected_withdraw(struct connected *ifc) | |
47 | { | |
48 | if (!ifc) | |
49 | return; | |
50 | ||
51 | /* Update interface address information to protocol daemon. */ | |
52 | if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) { | |
53 | zebra_interface_address_delete_update(ifc->ifp, ifc); | |
54 | ||
55 | if (ifc->address->family == AF_INET) | |
56 | if_subnet_delete(ifc->ifp, ifc); | |
57 | ||
58 | connected_down(ifc->ifp, ifc); | |
59 | ||
60 | UNSET_FLAG(ifc->conf, ZEBRA_IFC_REAL); | |
61 | } | |
62 | ||
63 | /* The address is not in the kernel anymore, so clear the flag */ | |
64 | UNSET_FLAG(ifc->conf, ZEBRA_IFC_QUEUED); | |
65 | ||
66 | if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED)) { | |
67 | listnode_delete(ifc->ifp->connected, ifc); | |
68 | connected_free(ifc); | |
69 | } | |
70 | } | |
71 | ||
72 | static void connected_announce(struct interface *ifp, struct connected *ifc) | |
73 | { | |
74 | if (!ifc) | |
75 | return; | |
76 | ||
77 | if (!if_is_loopback(ifp) && ifc->address->family == AF_INET && | |
78 | !IS_ZEBRA_IF_VRF(ifp)) { | |
79 | if (ifc->address->prefixlen == 32) | |
80 | SET_FLAG(ifc->flags, ZEBRA_IFA_UNNUMBERED); | |
81 | else | |
82 | UNSET_FLAG(ifc->flags, ZEBRA_IFA_UNNUMBERED); | |
83 | } | |
84 | ||
85 | listnode_add(ifp->connected, ifc); | |
86 | ||
87 | /* Update interface address information to protocol daemon. */ | |
88 | if (ifc->address->family == AF_INET) | |
89 | if_subnet_add(ifp, ifc); | |
90 | ||
91 | zebra_interface_address_add_update(ifp, ifc); | |
92 | ||
93 | if (if_is_operative(ifp)) { | |
94 | connected_up(ifp, ifc); | |
95 | } | |
96 | } | |
97 | ||
98 | /* If same interface address is already exist... */ | |
99 | struct connected *connected_check(struct interface *ifp, | |
100 | union prefixconstptr pu) | |
101 | { | |
102 | const struct prefix *p = pu.p; | |
103 | struct connected *ifc; | |
104 | struct listnode *node; | |
105 | ||
106 | for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) | |
107 | if (prefix_same(ifc->address, p)) | |
108 | return ifc; | |
109 | ||
110 | return NULL; | |
111 | } | |
112 | ||
113 | /* same, but with peer address */ | |
114 | struct connected *connected_check_ptp(struct interface *ifp, | |
115 | union prefixconstptr pu, | |
116 | union prefixconstptr du) | |
117 | { | |
118 | const struct prefix *p = pu.p; | |
119 | const struct prefix *d = du.p; | |
120 | struct connected *ifc; | |
121 | struct listnode *node; | |
122 | ||
123 | /* ignore broadcast addresses */ | |
124 | if (p->prefixlen != IPV4_MAX_PREFIXLEN) | |
125 | d = NULL; | |
126 | ||
127 | for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) { | |
128 | if (!prefix_same(ifc->address, p)) | |
129 | continue; | |
130 | if (!CONNECTED_PEER(ifc) && !d) | |
131 | return ifc; | |
132 | if (CONNECTED_PEER(ifc) && d | |
133 | && prefix_same(ifc->destination, d)) | |
134 | return ifc; | |
135 | } | |
136 | ||
137 | return NULL; | |
138 | } | |
139 | ||
140 | /* Check if two ifc's describe the same address in the same state */ | |
141 | static int connected_same(struct connected *ifc1, struct connected *ifc2) | |
142 | { | |
143 | if (ifc1->ifp != ifc2->ifp) | |
144 | return 0; | |
145 | ||
146 | if (ifc1->destination) | |
147 | if (!ifc2->destination) | |
148 | return 0; | |
149 | if (ifc2->destination) | |
150 | if (!ifc1->destination) | |
151 | return 0; | |
152 | ||
153 | if (ifc1->destination && ifc2->destination) | |
154 | if (!prefix_same(ifc1->destination, ifc2->destination)) | |
155 | return 0; | |
156 | ||
157 | if (ifc1->flags != ifc2->flags) | |
158 | return 0; | |
159 | ||
160 | if (ifc1->conf != ifc2->conf) | |
161 | return 0; | |
162 | ||
163 | return 1; | |
164 | } | |
165 | ||
166 | /* Handle changes to addresses and send the neccesary announcements | |
167 | * to clients. */ | |
168 | static void connected_update(struct interface *ifp, struct connected *ifc) | |
169 | { | |
170 | struct connected *current; | |
171 | ||
172 | /* Check same connected route. */ | |
173 | current = connected_check_ptp(ifp, ifc->address, ifc->destination); | |
174 | if (current) { | |
175 | if (CHECK_FLAG(current->conf, ZEBRA_IFC_CONFIGURED)) | |
176 | SET_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED); | |
177 | ||
178 | /* Avoid spurious withdraws, this might be just the kernel | |
179 | * 'reflecting' | |
180 | * back an address we have already added. | |
181 | */ | |
182 | if (connected_same(current, ifc)) { | |
183 | /* nothing to do */ | |
184 | connected_free(ifc); | |
185 | return; | |
186 | } | |
187 | ||
188 | /* Clear the configured flag on the old ifc, so it will be freed | |
189 | * by | |
190 | * connected withdraw. */ | |
191 | UNSET_FLAG(current->conf, ZEBRA_IFC_CONFIGURED); | |
192 | connected_withdraw( | |
193 | current); /* implicit withdraw - freebsd does this */ | |
194 | } | |
195 | ||
196 | /* If the connected is new or has changed, announce it, if it is usable | |
197 | */ | |
198 | if (CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) | |
199 | connected_announce(ifp, ifc); | |
200 | } | |
201 | ||
202 | /* Called from if_up(). */ | |
203 | void connected_up(struct interface *ifp, struct connected *ifc) | |
204 | { | |
205 | afi_t afi; | |
206 | struct prefix p; | |
207 | struct nexthop nh = { | |
208 | .type = NEXTHOP_TYPE_IFINDEX, | |
209 | .ifindex = ifp->ifindex, | |
210 | .vrf_id = ifp->vrf_id, | |
211 | }; | |
212 | ||
213 | if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) | |
214 | return; | |
215 | ||
216 | PREFIX_COPY(&p, CONNECTED_PREFIX(ifc)); | |
217 | ||
218 | /* Apply mask to the network. */ | |
219 | apply_mask(&p); | |
220 | ||
221 | afi = family2afi(p.family); | |
222 | ||
223 | switch (afi) { | |
224 | case AFI_IP: | |
225 | /* | |
226 | * In case of connected address is 0.0.0.0/0 we treat it tunnel | |
227 | * address. | |
228 | */ | |
229 | if (prefix_ipv4_any((struct prefix_ipv4 *)&p)) | |
230 | return; | |
231 | break; | |
232 | case AFI_IP6: | |
233 | #ifndef LINUX | |
234 | /* XXX: It is already done by rib_bogus_ipv6 within rib_add */ | |
235 | if (IN6_IS_ADDR_UNSPECIFIED(&p.u.prefix6)) | |
236 | return; | |
237 | #endif | |
238 | break; | |
239 | default: | |
240 | flog_warn(EC_ZEBRA_CONNECTED_AFI_UNKNOWN, | |
241 | "Received unknown AFI: %s", afi2str(afi)); | |
242 | return; | |
243 | break; | |
244 | } | |
245 | ||
246 | rib_add(afi, SAFI_UNICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, &p, | |
247 | NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0); | |
248 | ||
249 | rib_add(afi, SAFI_MULTICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, &p, | |
250 | NULL, &nh, RT_TABLE_MAIN, ifp->metric, 0, 0, 0); | |
251 | ||
252 | if (IS_ZEBRA_DEBUG_RIB_DETAILED) { | |
253 | char buf[PREFIX_STRLEN]; | |
254 | ||
255 | zlog_debug( | |
256 | "%u: IF %s address %s add/up, scheduling RIB processing", | |
257 | ifp->vrf_id, ifp->name, | |
258 | prefix2str(&p, buf, sizeof(buf))); | |
259 | } | |
260 | rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE); | |
261 | ||
262 | /* Schedule LSP forwarding entries for processing, if appropriate. */ | |
263 | if (ifp->vrf_id == VRF_DEFAULT) { | |
264 | if (IS_ZEBRA_DEBUG_MPLS) { | |
265 | char buf[PREFIX_STRLEN]; | |
266 | ||
267 | zlog_debug( | |
268 | "%u: IF %s IP %s address add/up, scheduling MPLS processing", | |
269 | ifp->vrf_id, ifp->name, | |
270 | prefix2str(&p, buf, sizeof(buf))); | |
271 | } | |
272 | mpls_mark_lsps_for_processing(vrf_info_lookup(ifp->vrf_id)); | |
273 | } | |
274 | } | |
275 | ||
276 | /* Add connected IPv4 route to the interface. */ | |
277 | void connected_add_ipv4(struct interface *ifp, int flags, struct in_addr *addr, | |
278 | uint8_t prefixlen, struct in_addr *broad, | |
279 | const char *label) | |
280 | { | |
281 | struct prefix_ipv4 *p; | |
282 | struct connected *ifc; | |
283 | ||
284 | if (ipv4_martian(addr)) | |
285 | return; | |
286 | ||
287 | /* Make connected structure. */ | |
288 | ifc = connected_new(); | |
289 | ifc->ifp = ifp; | |
290 | ifc->flags = flags; | |
291 | /* If we get a notification from the kernel, | |
292 | * we can safely assume the address is known to the kernel */ | |
293 | SET_FLAG(ifc->conf, ZEBRA_IFC_QUEUED); | |
294 | ||
295 | /* Allocate new connected address. */ | |
296 | p = prefix_ipv4_new(); | |
297 | p->family = AF_INET; | |
298 | p->prefix = *addr; | |
299 | p->prefixlen = CHECK_FLAG(flags, ZEBRA_IFA_PEER) ? IPV4_MAX_PREFIXLEN | |
300 | : prefixlen; | |
301 | ifc->address = (struct prefix *)p; | |
302 | ||
303 | /* If there is broadcast or peer address. */ | |
304 | if (broad) { | |
305 | p = prefix_ipv4_new(); | |
306 | p->family = AF_INET; | |
307 | p->prefix = *broad; | |
308 | p->prefixlen = prefixlen; | |
309 | ifc->destination = (struct prefix *)p; | |
310 | ||
311 | /* validate the destination address */ | |
312 | if (CONNECTED_PEER(ifc)) { | |
313 | if (IPV4_ADDR_SAME(addr, broad)) | |
314 | flog_warn( | |
315 | EC_ZEBRA_IFACE_SAME_LOCAL_AS_PEER, | |
316 | "warning: interface %s has same local and peer " | |
317 | "address %s, routing protocols may malfunction", | |
318 | ifp->name, inet_ntoa(*addr)); | |
319 | } else { | |
320 | if (broad->s_addr | |
321 | != ipv4_broadcast_addr(addr->s_addr, prefixlen)) { | |
322 | char buf[2][INET_ADDRSTRLEN]; | |
323 | struct in_addr bcalc; | |
324 | bcalc.s_addr = ipv4_broadcast_addr(addr->s_addr, | |
325 | prefixlen); | |
326 | flog_warn( | |
327 | EC_ZEBRA_BCAST_ADDR_MISMATCH, | |
328 | "warning: interface %s broadcast addr %s/%d != " | |
329 | "calculated %s, routing protocols may malfunction", | |
330 | ifp->name, | |
331 | inet_ntop(AF_INET, broad, buf[0], | |
332 | sizeof(buf[0])), | |
333 | prefixlen, | |
334 | inet_ntop(AF_INET, &bcalc, buf[1], | |
335 | sizeof(buf[1]))); | |
336 | } | |
337 | } | |
338 | ||
339 | } else { | |
340 | if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_PEER)) { | |
341 | zlog_debug( | |
342 | "warning: %s called for interface %s " | |
343 | "with peer flag set, but no peer address supplied", | |
344 | __func__, ifp->name); | |
345 | UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER); | |
346 | } | |
347 | ||
348 | /* no broadcast or destination address was supplied */ | |
349 | if ((prefixlen == IPV4_MAX_PREFIXLEN) && if_is_pointopoint(ifp)) | |
350 | zlog_debug( | |
351 | "warning: PtP interface %s with addr %s/%d needs a " | |
352 | "peer address", | |
353 | ifp->name, inet_ntoa(*addr), prefixlen); | |
354 | } | |
355 | ||
356 | /* Label of this address. */ | |
357 | if (label) | |
358 | ifc->label = XSTRDUP(MTYPE_CONNECTED_LABEL, label); | |
359 | ||
360 | /* For all that I know an IPv4 address is always ready when we receive | |
361 | * the notification. So it should be safe to set the REAL flag here. */ | |
362 | SET_FLAG(ifc->conf, ZEBRA_IFC_REAL); | |
363 | ||
364 | connected_update(ifp, ifc); | |
365 | } | |
366 | ||
367 | void connected_down(struct interface *ifp, struct connected *ifc) | |
368 | { | |
369 | afi_t afi; | |
370 | struct prefix p; | |
371 | struct nexthop nh = { | |
372 | .type = NEXTHOP_TYPE_IFINDEX, | |
373 | .ifindex = ifp->ifindex, | |
374 | .vrf_id = ifp->vrf_id, | |
375 | }; | |
376 | ||
377 | if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) | |
378 | return; | |
379 | ||
380 | PREFIX_COPY(&p, CONNECTED_PREFIX(ifc)); | |
381 | ||
382 | /* Apply mask to the network. */ | |
383 | apply_mask(&p); | |
384 | ||
385 | afi = family2afi(p.family); | |
386 | ||
387 | switch (afi) { | |
388 | case AFI_IP: | |
389 | /* | |
390 | * In case of connected address is 0.0.0.0/0 we treat it tunnel | |
391 | * address. | |
392 | */ | |
393 | if (prefix_ipv4_any((struct prefix_ipv4 *)&p)) | |
394 | return; | |
395 | break; | |
396 | case AFI_IP6: | |
397 | if (IN6_IS_ADDR_UNSPECIFIED(&p.u.prefix6)) | |
398 | return; | |
399 | break; | |
400 | default: | |
401 | zlog_info("Unknown AFI: %s", afi2str(afi)); | |
402 | break; | |
403 | } | |
404 | ||
405 | /* | |
406 | * Same logic as for connected_up(): push the changes into the | |
407 | * head. | |
408 | */ | |
409 | rib_delete(afi, SAFI_UNICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, | |
410 | &p, NULL, &nh, 0, 0, 0, false); | |
411 | ||
412 | rib_delete(afi, SAFI_MULTICAST, ifp->vrf_id, ZEBRA_ROUTE_CONNECT, 0, 0, | |
413 | &p, NULL, &nh, 0, 0, 0, false); | |
414 | ||
415 | if (IS_ZEBRA_DEBUG_RIB_DETAILED) { | |
416 | char buf[PREFIX_STRLEN]; | |
417 | ||
418 | zlog_debug( | |
419 | "%u: IF %s IP %s address down, scheduling RIB processing", | |
420 | ifp->vrf_id, ifp->name, | |
421 | prefix2str(&p, buf, sizeof(buf))); | |
422 | } | |
423 | ||
424 | rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE); | |
425 | ||
426 | /* Schedule LSP forwarding entries for processing, if appropriate. */ | |
427 | if (ifp->vrf_id == VRF_DEFAULT) { | |
428 | if (IS_ZEBRA_DEBUG_MPLS) { | |
429 | char buf[PREFIX_STRLEN]; | |
430 | ||
431 | zlog_debug( | |
432 | "%u: IF %s IP %s address down, scheduling MPLS processing", | |
433 | ifp->vrf_id, ifp->name, | |
434 | prefix2str(&p, buf, sizeof(buf))); | |
435 | } | |
436 | mpls_mark_lsps_for_processing(vrf_info_lookup(ifp->vrf_id)); | |
437 | } | |
438 | } | |
439 | ||
440 | static void connected_delete_helper(struct connected *ifc, struct prefix *p) | |
441 | { | |
442 | struct interface *ifp; | |
443 | ||
444 | if (!ifc) | |
445 | return; | |
446 | ifp = ifc->ifp; | |
447 | ||
448 | connected_withdraw(ifc); | |
449 | ||
450 | if (IS_ZEBRA_DEBUG_RIB_DETAILED) { | |
451 | char buf[PREFIX_STRLEN]; | |
452 | ||
453 | zlog_debug( | |
454 | "%u: IF %s IP %s address del, scheduling RIB processing", | |
455 | ifp->vrf_id, ifp->name, | |
456 | prefix2str(p, buf, sizeof(buf))); | |
457 | } | |
458 | rib_update(ifp->vrf_id, RIB_UPDATE_IF_CHANGE); | |
459 | ||
460 | /* Schedule LSP forwarding entries for processing, if appropriate. */ | |
461 | if (ifp->vrf_id == VRF_DEFAULT) { | |
462 | if (IS_ZEBRA_DEBUG_MPLS) { | |
463 | char buf[PREFIX_STRLEN]; | |
464 | ||
465 | zlog_debug( | |
466 | "%u: IF %s IP %s address delete, scheduling MPLS processing", | |
467 | ifp->vrf_id, ifp->name, | |
468 | prefix2str(p, buf, sizeof(buf))); | |
469 | } | |
470 | mpls_mark_lsps_for_processing(vrf_info_lookup(ifp->vrf_id)); | |
471 | } | |
472 | } | |
473 | ||
474 | /* Delete connected IPv4 route to the interface. */ | |
475 | void connected_delete_ipv4(struct interface *ifp, int flags, | |
476 | struct in_addr *addr, uint8_t prefixlen, | |
477 | struct in_addr *broad) | |
478 | { | |
479 | struct prefix p, d; | |
480 | struct connected *ifc; | |
481 | ||
482 | memset(&p, 0, sizeof(struct prefix)); | |
483 | p.family = AF_INET; | |
484 | p.u.prefix4 = *addr; | |
485 | p.prefixlen = CHECK_FLAG(flags, ZEBRA_IFA_PEER) ? IPV4_MAX_PREFIXLEN | |
486 | : prefixlen; | |
487 | ||
488 | if (broad) { | |
489 | memset(&d, 0, sizeof(struct prefix)); | |
490 | d.family = AF_INET; | |
491 | d.u.prefix4 = *broad; | |
492 | d.prefixlen = prefixlen; | |
493 | ifc = connected_check_ptp(ifp, &p, &d); | |
494 | } else | |
495 | ifc = connected_check_ptp(ifp, &p, NULL); | |
496 | ||
497 | connected_delete_helper(ifc, &p); | |
498 | } | |
499 | ||
500 | /* Add connected IPv6 route to the interface. */ | |
501 | void connected_add_ipv6(struct interface *ifp, int flags, struct in6_addr *addr, | |
502 | struct in6_addr *broad, uint8_t prefixlen, | |
503 | const char *label) | |
504 | { | |
505 | struct prefix_ipv6 *p; | |
506 | struct connected *ifc; | |
507 | ||
508 | if (ipv6_martian(addr)) | |
509 | return; | |
510 | ||
511 | /* Make connected structure. */ | |
512 | ifc = connected_new(); | |
513 | ifc->ifp = ifp; | |
514 | ifc->flags = flags; | |
515 | /* If we get a notification from the kernel, | |
516 | * we can safely assume the address is known to the kernel */ | |
517 | SET_FLAG(ifc->conf, ZEBRA_IFC_QUEUED); | |
518 | ||
519 | /* Allocate new connected address. */ | |
520 | p = prefix_ipv6_new(); | |
521 | p->family = AF_INET6; | |
522 | IPV6_ADDR_COPY(&p->prefix, addr); | |
523 | p->prefixlen = prefixlen; | |
524 | ifc->address = (struct prefix *)p; | |
525 | ||
526 | if (broad) { | |
527 | p = prefix_ipv6_new(); | |
528 | p->family = AF_INET6; | |
529 | IPV6_ADDR_COPY(&p->prefix, broad); | |
530 | p->prefixlen = prefixlen; | |
531 | ifc->destination = (struct prefix *)p; | |
532 | } else { | |
533 | if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_PEER)) { | |
534 | zlog_debug( | |
535 | "warning: %s called for interface %s with peer flag set, but no peer address supplied", | |
536 | __func__, ifp->name); | |
537 | UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER); | |
538 | } | |
539 | } | |
540 | ||
541 | /* Label of this address. */ | |
542 | if (label) | |
543 | ifc->label = XSTRDUP(MTYPE_CONNECTED_LABEL, label); | |
544 | ||
545 | /* On Linux, we only get here when DAD is complete, therefore we can set | |
546 | * ZEBRA_IFC_REAL. | |
547 | * | |
548 | * On BSD, there currently doesn't seem to be a way to check for | |
549 | * completion of | |
550 | * DAD, so we replicate the old behaviour and set ZEBRA_IFC_REAL, | |
551 | * although DAD | |
552 | * might still be running. | |
553 | */ | |
554 | SET_FLAG(ifc->conf, ZEBRA_IFC_REAL); | |
555 | connected_update(ifp, ifc); | |
556 | } | |
557 | ||
558 | void connected_delete_ipv6(struct interface *ifp, struct in6_addr *address, | |
559 | struct in6_addr *broad, uint8_t prefixlen) | |
560 | { | |
561 | struct prefix p, d; | |
562 | struct connected *ifc; | |
563 | ||
564 | memset(&p, 0, sizeof(struct prefix)); | |
565 | p.family = AF_INET6; | |
566 | memcpy(&p.u.prefix6, address, sizeof(struct in6_addr)); | |
567 | p.prefixlen = prefixlen; | |
568 | ||
569 | if (broad) { | |
570 | memset(&d, 0, sizeof(struct prefix)); | |
571 | d.family = AF_INET6; | |
572 | IPV6_ADDR_COPY(&d.u.prefix6, broad); | |
573 | d.prefixlen = prefixlen; | |
574 | ifc = connected_check_ptp(ifp, &p, &d); | |
575 | } else | |
576 | ifc = connected_check_ptp(ifp, &p, NULL); | |
577 | ||
578 | connected_delete_helper(ifc, &p); | |
579 | } | |
580 | ||
581 | int connected_is_unnumbered(struct interface *ifp) | |
582 | { | |
583 | struct connected *connected; | |
584 | struct listnode *node; | |
585 | ||
586 | for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) { | |
587 | if (CHECK_FLAG(connected->conf, ZEBRA_IFC_REAL) | |
588 | && connected->address->family == AF_INET) | |
589 | return CHECK_FLAG(connected->flags, | |
590 | ZEBRA_IFA_UNNUMBERED); | |
591 | } | |
592 | return 0; | |
593 | } |