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