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