]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * Interface related function for RIPng. | |
3 | * Copyright (C) 1998 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 "linklist.h" | |
26 | #include "if.h" | |
27 | #include "prefix.h" | |
28 | #include "memory.h" | |
29 | #include "network.h" | |
30 | #include "filter.h" | |
31 | #include "log.h" | |
32 | #include "stream.h" | |
33 | #include "zclient.h" | |
34 | #include "command.h" | |
35 | #include "table.h" | |
36 | #include "thread.h" | |
4d4653af | 37 | #include "privs.h" |
6a69b354 | 38 | #include "vrf.h" |
718e3744 | 39 | |
40 | #include "ripngd/ripngd.h" | |
41 | #include "ripngd/ripng_debug.h" | |
6b0655a2 | 42 | |
718e3744 | 43 | /* If RFC2133 definition is used. */ |
44 | #ifndef IPV6_JOIN_GROUP | |
45 | #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP | |
46 | #endif | |
47 | #ifndef IPV6_LEAVE_GROUP | |
48 | #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP | |
49 | #endif | |
50 | ||
4d4653af | 51 | extern struct zebra_privs_t ripngd_privs; |
52 | ||
718e3744 | 53 | /* Static utility function. */ |
54 | static void ripng_enable_apply (struct interface *); | |
55 | static void ripng_passive_interface_apply (struct interface *); | |
6ac29a51 PJ |
56 | static int ripng_enable_if_lookup (const char *); |
57 | static int ripng_enable_network_lookup2 (struct connected *); | |
58 | static void ripng_enable_apply_all (void); | |
718e3744 | 59 | |
60 | /* Join to the all rip routers multicast group. */ | |
6ac29a51 | 61 | static int |
718e3744 | 62 | ripng_multicast_join (struct interface *ifp) |
63 | { | |
64 | int ret; | |
65 | struct ipv6_mreq mreq; | |
656b4eee | 66 | int save_errno; |
718e3744 | 67 | |
9e544a9c | 68 | if (if_is_multicast (ifp)) { |
a94434b6 | 69 | memset (&mreq, 0, sizeof (mreq)); |
70 | inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); | |
71 | mreq.ipv6mr_interface = ifp->ifindex; | |
718e3744 | 72 | |
4d4653af | 73 | /* |
74 | * NetBSD 1.6.2 requires root to join groups on gif(4). | |
75 | * While this is bogus, privs are available and easy to use | |
76 | * for this call as a workaround. | |
77 | */ | |
78 | if (ripngd_privs.change (ZPRIVS_RAISE)) | |
79 | zlog_err ("ripng_multicast_join: could not raise privs"); | |
80 | ||
a94434b6 | 81 | ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, |
82 | (char *) &mreq, sizeof (mreq)); | |
656b4eee | 83 | save_errno = errno; |
ddf1c26c | 84 | |
4d4653af | 85 | if (ripngd_privs.change (ZPRIVS_LOWER)) |
86 | zlog_err ("ripng_multicast_join: could not lower privs"); | |
87 | ||
656b4eee | 88 | if (ret < 0 && save_errno == EADDRINUSE) |
ddf1c26c | 89 | { |
90 | /* | |
91 | * Group is already joined. This occurs due to sloppy group | |
92 | * management, in particular declining to leave the group on | |
93 | * an interface that has just gone down. | |
94 | */ | |
95 | zlog_warn ("ripng join on %s EADDRINUSE (ignoring)\n", ifp->name); | |
96 | return 0; /* not an error */ | |
97 | } | |
98 | ||
a94434b6 | 99 | if (ret < 0) |
656b4eee | 100 | zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s", |
101 | safe_strerror (save_errno)); | |
718e3744 | 102 | |
a94434b6 | 103 | if (IS_RIPNG_DEBUG_EVENT) |
2e23ab2e | 104 | zlog_debug ("RIPng %s join to all-rip-routers multicast group", ifp->name); |
718e3744 | 105 | |
a94434b6 | 106 | if (ret < 0) |
107 | return -1; | |
108 | } | |
109 | return 0; | |
718e3744 | 110 | } |
111 | ||
112 | /* Leave from the all rip routers multicast group. */ | |
6ac29a51 | 113 | static int |
718e3744 | 114 | ripng_multicast_leave (struct interface *ifp) |
115 | { | |
116 | int ret; | |
117 | struct ipv6_mreq mreq; | |
118 | ||
9e544a9c | 119 | if (if_is_multicast (ifp)) { |
a94434b6 | 120 | memset (&mreq, 0, sizeof (mreq)); |
121 | inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); | |
122 | mreq.ipv6mr_interface = ifp->ifindex; | |
718e3744 | 123 | |
a94434b6 | 124 | ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, |
125 | (char *) &mreq, sizeof (mreq)); | |
126 | if (ret < 0) | |
6099b3b5 | 127 | zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", safe_strerror (errno)); |
a94434b6 | 128 | |
129 | if (IS_RIPNG_DEBUG_EVENT) | |
2e23ab2e | 130 | zlog_debug ("RIPng %s leave from all-rip-routers multicast group", |
a94434b6 | 131 | ifp->name); |
132 | ||
133 | if (ret < 0) | |
134 | return -1; | |
135 | } | |
136 | ||
137 | return 0; | |
138 | } | |
139 | ||
140 | /* How many link local IPv6 address could be used on the interface ? */ | |
6ac29a51 | 141 | static int |
a94434b6 | 142 | ripng_if_ipv6_lladdress_check (struct interface *ifp) |
143 | { | |
144 | struct listnode *nn; | |
145 | struct connected *connected; | |
146 | int count = 0; | |
147 | ||
1eb8ef25 | 148 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected)) |
149 | { | |
a94434b6 | 150 | struct prefix *p; |
151 | p = connected->address; | |
718e3744 | 152 | |
a94434b6 | 153 | if ((p->family == AF_INET6) && |
154 | IN6_IS_ADDR_LINKLOCAL (&p->u.prefix6)) | |
155 | count++; | |
156 | } | |
718e3744 | 157 | |
a94434b6 | 158 | return count; |
718e3744 | 159 | } |
160 | ||
6ac29a51 | 161 | static int |
718e3744 | 162 | ripng_if_down (struct interface *ifp) |
163 | { | |
164 | struct route_node *rp; | |
165 | struct ripng_info *rinfo; | |
166 | struct ripng_interface *ri; | |
c880b636 FL |
167 | struct list *list = NULL; |
168 | struct listnode *listnode = NULL, *nextnode = NULL; | |
718e3744 | 169 | |
a94434b6 | 170 | if (ripng) |
c880b636 FL |
171 | for (rp = route_top (ripng->table); rp; rp = route_next (rp)) |
172 | if ((list = rp->info) != NULL) | |
173 | for (ALL_LIST_ELEMENTS (list, listnode, nextnode, rinfo)) | |
174 | if (rinfo->ifindex == ifp->ifindex) | |
175 | ripng_ecmp_delete (rinfo); | |
718e3744 | 176 | |
177 | ri = ifp->info; | |
178 | ||
a94434b6 | 179 | if (ri->running) |
718e3744 | 180 | { |
181 | if (IS_RIPNG_DEBUG_EVENT) | |
2e23ab2e | 182 | zlog_debug ("turn off %s", ifp->name); |
718e3744 | 183 | |
184 | /* Leave from multicast group. */ | |
185 | ripng_multicast_leave (ifp); | |
186 | ||
187 | ri->running = 0; | |
188 | } | |
189 | ||
190 | return 0; | |
191 | } | |
192 | ||
193 | /* Inteface link up message processing. */ | |
194 | int | |
7076bb2f FL |
195 | ripng_interface_up (int command, struct zclient *zclient, zebra_size_t length, |
196 | vrf_id_t vrf_id) | |
718e3744 | 197 | { |
198 | struct stream *s; | |
199 | struct interface *ifp; | |
200 | ||
201 | /* zebra_interface_state_read() updates interface structure in iflist. */ | |
202 | s = zclient->ibuf; | |
7076bb2f | 203 | ifp = zebra_interface_state_read (s, vrf_id); |
718e3744 | 204 | |
205 | if (ifp == NULL) | |
206 | return 0; | |
207 | ||
208 | if (IS_RIPNG_DEBUG_ZEBRA) | |
30d20590 SH |
209 | zlog_debug ("interface up %s index %d flags %llx metric %d mtu %d", |
210 | ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, | |
211 | ifp->metric, ifp->mtu6); | |
718e3744 | 212 | |
213 | /* Check if this interface is RIPng enabled or not. */ | |
214 | ripng_enable_apply (ifp); | |
215 | ||
216 | /* Check for a passive interface. */ | |
217 | ripng_passive_interface_apply (ifp); | |
218 | ||
219 | /* Apply distribute list to the all interface. */ | |
220 | ripng_distribute_update_interface (ifp); | |
221 | ||
222 | return 0; | |
223 | } | |
224 | ||
225 | /* Inteface link down message processing. */ | |
226 | int | |
227 | ripng_interface_down (int command, struct zclient *zclient, | |
7076bb2f | 228 | zebra_size_t length, vrf_id_t vrf_id) |
718e3744 | 229 | { |
230 | struct stream *s; | |
231 | struct interface *ifp; | |
232 | ||
233 | /* zebra_interface_state_read() updates interface structure in iflist. */ | |
234 | s = zclient->ibuf; | |
7076bb2f | 235 | ifp = zebra_interface_state_read (s, vrf_id); |
718e3744 | 236 | |
237 | if (ifp == NULL) | |
238 | return 0; | |
239 | ||
240 | ripng_if_down (ifp); | |
241 | ||
242 | if (IS_RIPNG_DEBUG_ZEBRA) | |
5eb9d11b SH |
243 | zlog_debug ("interface down %s index %d flags %#llx metric %d mtu %d", |
244 | ifp->name, ifp->ifindex, | |
245 | (unsigned long long) ifp->flags, ifp->metric, ifp->mtu6); | |
718e3744 | 246 | |
247 | return 0; | |
248 | } | |
249 | ||
250 | /* Inteface addition message from zebra. */ | |
251 | int | |
7076bb2f FL |
252 | ripng_interface_add (int command, struct zclient *zclient, zebra_size_t length, |
253 | vrf_id_t vrf_id) | |
718e3744 | 254 | { |
255 | struct interface *ifp; | |
256 | ||
7076bb2f | 257 | ifp = zebra_interface_add_read (zclient->ibuf, vrf_id); |
718e3744 | 258 | |
259 | if (IS_RIPNG_DEBUG_ZEBRA) | |
5eb9d11b SH |
260 | zlog_debug ("RIPng interface add %s index %d flags %#llx metric %d mtu %d", |
261 | ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, | |
262 | ifp->metric, ifp->mtu6); | |
718e3744 | 263 | |
264 | /* Check is this interface is RIP enabled or not.*/ | |
265 | ripng_enable_apply (ifp); | |
266 | ||
267 | /* Apply distribute list to the interface. */ | |
268 | ripng_distribute_update_interface (ifp); | |
269 | ||
270 | /* Check interface routemap. */ | |
271 | ripng_if_rmap_update_interface (ifp); | |
272 | ||
273 | return 0; | |
274 | } | |
275 | ||
276 | int | |
277 | ripng_interface_delete (int command, struct zclient *zclient, | |
7076bb2f | 278 | zebra_size_t length, vrf_id_t vrf_id) |
718e3744 | 279 | { |
a94434b6 | 280 | struct interface *ifp; |
281 | struct stream *s; | |
282 | ||
283 | s = zclient->ibuf; | |
284 | /* zebra_interface_state_read() updates interface structure in iflist */ | |
7076bb2f | 285 | ifp = zebra_interface_state_read (s, vrf_id); |
a94434b6 | 286 | |
287 | if (ifp == NULL) | |
288 | return 0; | |
289 | ||
290 | if (if_is_up (ifp)) { | |
291 | ripng_if_down(ifp); | |
292 | } | |
293 | ||
5eb9d11b SH |
294 | zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d", |
295 | ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, | |
296 | ifp->metric, ifp->mtu6); | |
a94434b6 | 297 | |
298 | /* To support pseudo interface do not free interface structure. */ | |
299 | /* if_delete(ifp); */ | |
84361d61 | 300 | ifp->ifindex = IFINDEX_DELETED; |
a94434b6 | 301 | |
718e3744 | 302 | return 0; |
303 | } | |
304 | ||
a94434b6 | 305 | void |
6ac29a51 | 306 | ripng_interface_clean (void) |
a94434b6 | 307 | { |
1eb8ef25 | 308 | struct listnode *node, *nnode; |
a94434b6 | 309 | struct interface *ifp; |
310 | struct ripng_interface *ri; | |
311 | ||
b2d7c082 | 312 | for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), node, nnode, ifp)) |
a94434b6 | 313 | { |
a94434b6 | 314 | ri = ifp->info; |
315 | ||
316 | ri->enable_network = 0; | |
317 | ri->enable_interface = 0; | |
318 | ri->running = 0; | |
319 | ||
320 | if (ri->t_wakeup) | |
321 | { | |
322 | thread_cancel (ri->t_wakeup); | |
323 | ri->t_wakeup = NULL; | |
324 | } | |
325 | } | |
326 | } | |
327 | ||
328 | void | |
6ac29a51 PJ |
329 | ripng_interface_reset (void) |
330 | { | |
52dc7ee6 | 331 | struct listnode *node; |
a94434b6 | 332 | struct interface *ifp; |
333 | struct ripng_interface *ri; | |
334 | ||
b2d7c082 | 335 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
a94434b6 | 336 | { |
a94434b6 | 337 | ri = ifp->info; |
338 | ||
339 | ri->enable_network = 0; | |
340 | ri->enable_interface = 0; | |
341 | ri->running = 0; | |
342 | ||
343 | ri->split_horizon = RIPNG_NO_SPLIT_HORIZON; | |
344 | ri->split_horizon_default = RIPNG_NO_SPLIT_HORIZON; | |
345 | ||
346 | ri->list[RIPNG_FILTER_IN] = NULL; | |
347 | ri->list[RIPNG_FILTER_OUT] = NULL; | |
348 | ||
349 | ri->prefix[RIPNG_FILTER_IN] = NULL; | |
350 | ri->prefix[RIPNG_FILTER_OUT] = NULL; | |
351 | ||
352 | if (ri->t_wakeup) | |
353 | { | |
354 | thread_cancel (ri->t_wakeup); | |
355 | ri->t_wakeup = NULL; | |
356 | } | |
357 | ||
358 | ri->passive = 0; | |
359 | } | |
360 | } | |
361 | ||
362 | static void | |
363 | ripng_apply_address_add (struct connected *ifc) { | |
364 | struct prefix_ipv6 address; | |
365 | struct prefix *p; | |
366 | ||
367 | if (!ripng) | |
368 | return; | |
369 | ||
370 | if (! if_is_up(ifc->ifp)) | |
371 | return; | |
372 | ||
373 | p = ifc->address; | |
374 | ||
375 | memset (&address, 0, sizeof (address)); | |
376 | address.family = p->family; | |
377 | address.prefix = p->u.prefix6; | |
378 | address.prefixlen = p->prefixlen; | |
379 | apply_mask_ipv6(&address); | |
380 | ||
381 | /* Check if this interface is RIP enabled or not | |
382 | or Check if this address's prefix is RIP enabled */ | |
383 | if ((ripng_enable_if_lookup(ifc->ifp->name) >= 0) || | |
384 | (ripng_enable_network_lookup2(ifc) >= 0)) | |
385 | ripng_redistribute_add(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, | |
1796a585 | 386 | &address, ifc->ifp->ifindex, NULL, 0); |
a94434b6 | 387 | |
388 | } | |
389 | ||
718e3744 | 390 | int |
391 | ripng_interface_address_add (int command, struct zclient *zclient, | |
7076bb2f | 392 | zebra_size_t length, vrf_id_t vrf_id) |
718e3744 | 393 | { |
394 | struct connected *c; | |
395 | struct prefix *p; | |
718e3744 | 396 | |
0a589359 | 397 | c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, |
7076bb2f | 398 | zclient->ibuf, vrf_id); |
718e3744 | 399 | |
400 | if (c == NULL) | |
401 | return 0; | |
402 | ||
403 | p = c->address; | |
404 | ||
405 | if (p->family == AF_INET6) | |
406 | { | |
995b9651 PJ |
407 | struct ripng_interface *ri = c->ifp->info; |
408 | ||
718e3744 | 409 | if (IS_RIPNG_DEBUG_ZEBRA) |
2e23ab2e | 410 | zlog_debug ("RIPng connected address %s/%d add", |
3a2ce6a1 | 411 | inet6_ntoa(p->u.prefix6), |
718e3744 | 412 | p->prefixlen); |
413 | ||
a94434b6 | 414 | /* Check is this prefix needs to be redistributed. */ |
415 | ripng_apply_address_add(c); | |
416 | ||
417 | /* Let's try once again whether the interface could be activated */ | |
995b9651 PJ |
418 | if (!ri->running) { |
419 | /* Check if this interface is RIP enabled or not.*/ | |
420 | ripng_enable_apply (c->ifp); | |
a94434b6 | 421 | |
995b9651 PJ |
422 | /* Apply distribute list to the interface. */ |
423 | ripng_distribute_update_interface (c->ifp); | |
a94434b6 | 424 | |
995b9651 PJ |
425 | /* Check interface routemap. */ |
426 | ripng_if_rmap_update_interface (c->ifp); | |
a94434b6 | 427 | } |
428 | ||
718e3744 | 429 | } |
430 | ||
431 | return 0; | |
432 | } | |
433 | ||
a94434b6 | 434 | static void |
435 | ripng_apply_address_del (struct connected *ifc) { | |
436 | struct prefix_ipv6 address; | |
437 | struct prefix *p; | |
438 | ||
439 | if (!ripng) | |
440 | return; | |
441 | ||
442 | if (! if_is_up(ifc->ifp)) | |
443 | return; | |
444 | ||
445 | p = ifc->address; | |
446 | ||
447 | memset (&address, 0, sizeof (address)); | |
448 | address.family = p->family; | |
449 | address.prefix = p->u.prefix6; | |
450 | address.prefixlen = p->prefixlen; | |
451 | apply_mask_ipv6(&address); | |
452 | ||
453 | ripng_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, | |
454 | &address, ifc->ifp->ifindex); | |
455 | } | |
456 | ||
718e3744 | 457 | int |
458 | ripng_interface_address_delete (int command, struct zclient *zclient, | |
7076bb2f | 459 | zebra_size_t length, vrf_id_t vrf_id) |
718e3744 | 460 | { |
461 | struct connected *ifc; | |
462 | struct prefix *p; | |
463 | char buf[INET6_ADDRSTRLEN]; | |
464 | ||
0a589359 | 465 | ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, |
7076bb2f | 466 | zclient->ibuf, vrf_id); |
718e3744 | 467 | |
468 | if (ifc) | |
469 | { | |
470 | p = ifc->address; | |
471 | ||
472 | if (p->family == AF_INET6) | |
473 | { | |
474 | if (IS_RIPNG_DEBUG_ZEBRA) | |
2e23ab2e | 475 | zlog_debug ("RIPng connected address %s/%d delete", |
718e3744 | 476 | inet_ntop (AF_INET6, &p->u.prefix6, buf, |
477 | INET6_ADDRSTRLEN), | |
478 | p->prefixlen); | |
479 | ||
a94434b6 | 480 | /* Check wether this prefix needs to be removed. */ |
481 | ripng_apply_address_del(ifc); | |
718e3744 | 482 | } |
483 | connected_free (ifc); | |
484 | } | |
485 | ||
486 | return 0; | |
487 | } | |
6b0655a2 | 488 | |
718e3744 | 489 | /* RIPng enable interface vector. */ |
490 | vector ripng_enable_if; | |
491 | ||
492 | /* RIPng enable network table. */ | |
493 | struct route_table *ripng_enable_network; | |
494 | ||
495 | /* Lookup RIPng enable network. */ | |
a94434b6 | 496 | /* Check wether the interface has at least a connected prefix that |
497 | * is within the ripng_enable_network table. */ | |
6ac29a51 | 498 | static int |
a94434b6 | 499 | ripng_enable_network_lookup_if (struct interface *ifp) |
718e3744 | 500 | { |
1eb8ef25 | 501 | struct listnode *node; |
718e3744 | 502 | struct connected *connected; |
a94434b6 | 503 | struct prefix_ipv6 address; |
718e3744 | 504 | |
1eb8ef25 | 505 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) |
506 | { | |
507 | struct prefix *p; | |
508 | struct route_node *node; | |
718e3744 | 509 | |
1eb8ef25 | 510 | p = connected->address; |
a94434b6 | 511 | |
1eb8ef25 | 512 | if (p->family == AF_INET6) |
513 | { | |
514 | address.family = AF_INET6; | |
515 | address.prefix = p->u.prefix6; | |
516 | address.prefixlen = IPV6_MAX_BITLEN; | |
517 | ||
518 | node = route_node_match (ripng_enable_network, | |
519 | (struct prefix *)&address); | |
520 | if (node) | |
521 | { | |
522 | route_unlock_node (node); | |
523 | return 1; | |
524 | } | |
525 | } | |
526 | } | |
718e3744 | 527 | return -1; |
528 | } | |
529 | ||
a94434b6 | 530 | /* Check wether connected is within the ripng_enable_network table. */ |
6ac29a51 | 531 | static int |
a94434b6 | 532 | ripng_enable_network_lookup2 (struct connected *connected) |
533 | { | |
534 | struct prefix_ipv6 address; | |
535 | struct prefix *p; | |
536 | ||
537 | p = connected->address; | |
538 | ||
539 | if (p->family == AF_INET6) { | |
540 | struct route_node *node; | |
541 | ||
542 | address.family = p->family; | |
543 | address.prefix = p->u.prefix6; | |
544 | address.prefixlen = IPV6_MAX_BITLEN; | |
545 | ||
546 | /* LPM on p->family, p->u.prefix6/IPV6_MAX_BITLEN within ripng_enable_network */ | |
547 | node = route_node_match (ripng_enable_network, | |
548 | (struct prefix *)&address); | |
549 | ||
550 | if (node) { | |
551 | route_unlock_node (node); | |
552 | return 1; | |
553 | } | |
554 | } | |
555 | ||
556 | return -1; | |
557 | } | |
558 | ||
718e3744 | 559 | /* Add RIPng enable network. */ |
6ac29a51 | 560 | static int |
718e3744 | 561 | ripng_enable_network_add (struct prefix *p) |
562 | { | |
563 | struct route_node *node; | |
564 | ||
565 | node = route_node_get (ripng_enable_network, p); | |
566 | ||
567 | if (node->info) | |
568 | { | |
569 | route_unlock_node (node); | |
570 | return -1; | |
571 | } | |
572 | else | |
37477535 | 573 | node->info = (void *)1; |
718e3744 | 574 | |
a94434b6 | 575 | /* XXX: One should find a better solution than a generic one */ |
576 | ripng_enable_apply_all(); | |
577 | ||
718e3744 | 578 | return 1; |
579 | } | |
580 | ||
581 | /* Delete RIPng enable network. */ | |
6ac29a51 | 582 | static int |
718e3744 | 583 | ripng_enable_network_delete (struct prefix *p) |
584 | { | |
585 | struct route_node *node; | |
586 | ||
587 | node = route_node_lookup (ripng_enable_network, p); | |
588 | if (node) | |
589 | { | |
590 | node->info = NULL; | |
591 | ||
592 | /* Unlock info lock. */ | |
593 | route_unlock_node (node); | |
594 | ||
595 | /* Unlock lookup lock. */ | |
596 | route_unlock_node (node); | |
597 | ||
598 | return 1; | |
599 | } | |
600 | return -1; | |
601 | } | |
602 | ||
603 | /* Lookup function. */ | |
6ac29a51 | 604 | static int |
98b718a9 | 605 | ripng_enable_if_lookup (const char *ifname) |
718e3744 | 606 | { |
7a1d583c | 607 | unsigned int i; |
718e3744 | 608 | char *str; |
609 | ||
55468c86 | 610 | for (i = 0; i < vector_active (ripng_enable_if); i++) |
718e3744 | 611 | if ((str = vector_slot (ripng_enable_if, i)) != NULL) |
612 | if (strcmp (str, ifname) == 0) | |
613 | return i; | |
614 | return -1; | |
615 | } | |
616 | ||
617 | /* Add interface to ripng_enable_if. */ | |
6ac29a51 | 618 | static int |
98b718a9 | 619 | ripng_enable_if_add (const char *ifname) |
718e3744 | 620 | { |
621 | int ret; | |
622 | ||
623 | ret = ripng_enable_if_lookup (ifname); | |
624 | if (ret >= 0) | |
625 | return -1; | |
626 | ||
627 | vector_set (ripng_enable_if, strdup (ifname)); | |
628 | ||
a94434b6 | 629 | ripng_enable_apply_all(); |
630 | ||
718e3744 | 631 | return 1; |
632 | } | |
633 | ||
634 | /* Delete interface from ripng_enable_if. */ | |
6ac29a51 | 635 | static int |
98b718a9 | 636 | ripng_enable_if_delete (const char *ifname) |
718e3744 | 637 | { |
638 | int index; | |
639 | char *str; | |
640 | ||
641 | index = ripng_enable_if_lookup (ifname); | |
642 | if (index < 0) | |
643 | return -1; | |
644 | ||
645 | str = vector_slot (ripng_enable_if, index); | |
646 | free (str); | |
647 | vector_unset (ripng_enable_if, index); | |
648 | ||
a94434b6 | 649 | ripng_enable_apply_all(); |
650 | ||
718e3744 | 651 | return 1; |
652 | } | |
653 | ||
654 | /* Wake up interface. */ | |
6ac29a51 | 655 | static int |
718e3744 | 656 | ripng_interface_wakeup (struct thread *t) |
657 | { | |
658 | struct interface *ifp; | |
659 | struct ripng_interface *ri; | |
660 | ||
661 | /* Get interface. */ | |
662 | ifp = THREAD_ARG (t); | |
663 | ||
664 | ri = ifp->info; | |
665 | ri->t_wakeup = NULL; | |
666 | ||
667 | /* Join to multicast group. */ | |
a94434b6 | 668 | if (ripng_multicast_join (ifp) < 0) { |
669 | zlog_err ("multicast join failed, interface %s not running", ifp->name); | |
670 | return 0; | |
671 | } | |
672 | ||
673 | /* Set running flag. */ | |
674 | ri->running = 1; | |
718e3744 | 675 | |
676 | /* Send RIP request to the interface. */ | |
677 | ripng_request (ifp); | |
678 | ||
679 | return 0; | |
680 | } | |
681 | ||
6ac29a51 | 682 | static void |
a94434b6 | 683 | ripng_connect_set (struct interface *ifp, int set) |
684 | { | |
1eb8ef25 | 685 | struct listnode *node, *nnode; |
a94434b6 | 686 | struct connected *connected; |
687 | struct prefix_ipv6 address; | |
688 | ||
1eb8ef25 | 689 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected)) |
690 | { | |
a94434b6 | 691 | struct prefix *p; |
692 | p = connected->address; | |
693 | ||
694 | if (p->family != AF_INET6) | |
695 | continue; | |
696 | ||
697 | address.family = AF_INET6; | |
698 | address.prefix = p->u.prefix6; | |
699 | address.prefixlen = p->prefixlen; | |
700 | apply_mask_ipv6 (&address); | |
701 | ||
702 | if (set) { | |
703 | /* Check once more wether this prefix is within a "network IF_OR_PREF" one */ | |
704 | if ((ripng_enable_if_lookup(connected->ifp->name) >= 0) || | |
705 | (ripng_enable_network_lookup2(connected) >= 0)) | |
706 | ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, | |
1796a585 | 707 | &address, connected->ifp->ifindex, NULL, 0); |
a94434b6 | 708 | } else { |
709 | ripng_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_INTERFACE, | |
710 | &address, connected->ifp->ifindex); | |
711 | if (ripng_redistribute_check (ZEBRA_ROUTE_CONNECT)) | |
712 | ripng_redistribute_add (ZEBRA_ROUTE_CONNECT, RIPNG_ROUTE_REDISTRIBUTE, | |
1796a585 | 713 | &address, connected->ifp->ifindex, NULL, 0); |
a94434b6 | 714 | } |
715 | } | |
716 | } | |
717 | ||
718e3744 | 718 | /* Check RIPng is enabed on this interface. */ |
719 | void | |
720 | ripng_enable_apply (struct interface *ifp) | |
721 | { | |
722 | int ret; | |
723 | struct ripng_interface *ri = NULL; | |
724 | ||
725 | /* Check interface. */ | |
718e3744 | 726 | if (! if_is_up (ifp)) |
727 | return; | |
728 | ||
729 | ri = ifp->info; | |
730 | ||
a94434b6 | 731 | /* Is this interface a candidate for RIPng ? */ |
732 | ret = ripng_enable_network_lookup_if (ifp); | |
718e3744 | 733 | |
734 | /* If the interface is matched. */ | |
735 | if (ret > 0) | |
736 | ri->enable_network = 1; | |
737 | else | |
738 | ri->enable_network = 0; | |
739 | ||
740 | /* Check interface name configuration. */ | |
741 | ret = ripng_enable_if_lookup (ifp->name); | |
742 | if (ret >= 0) | |
743 | ri->enable_interface = 1; | |
744 | else | |
745 | ri->enable_interface = 0; | |
746 | ||
a94434b6 | 747 | /* any candidate interface MUST have a link-local IPv6 address */ |
748 | if ((! ripng_if_ipv6_lladdress_check (ifp)) && | |
749 | (ri->enable_network || ri->enable_interface)) { | |
750 | ri->enable_network = 0; | |
751 | ri->enable_interface = 0; | |
752 | zlog_warn("Interface %s does not have any link-local address", | |
753 | ifp->name); | |
754 | } | |
755 | ||
718e3744 | 756 | /* Update running status of the interface. */ |
757 | if (ri->enable_network || ri->enable_interface) | |
758 | { | |
718e3744 | 759 | { |
760 | if (IS_RIPNG_DEBUG_EVENT) | |
2e23ab2e | 761 | zlog_debug ("RIPng turn on %s", ifp->name); |
718e3744 | 762 | |
763 | /* Add interface wake up thread. */ | |
ffa2c898 QY |
764 | thread_add_timer(master, ripng_interface_wakeup, ifp, 1, |
765 | &ri->t_wakeup); | |
718e3744 | 766 | |
a94434b6 | 767 | ripng_connect_set (ifp, 1); |
718e3744 | 768 | } |
769 | } | |
770 | else | |
771 | { | |
772 | if (ri->running) | |
773 | { | |
a94434b6 | 774 | /* Might as well clean up the route table as well |
775 | * ripng_if_down sets to 0 ri->running, and displays "turn off %s" | |
776 | **/ | |
777 | ripng_if_down(ifp); | |
718e3744 | 778 | |
a94434b6 | 779 | ripng_connect_set (ifp, 0); |
718e3744 | 780 | } |
781 | } | |
782 | } | |
783 | ||
784 | /* Set distribute list to all interfaces. */ | |
6ac29a51 PJ |
785 | static void |
786 | ripng_enable_apply_all (void) | |
718e3744 | 787 | { |
788 | struct interface *ifp; | |
52dc7ee6 | 789 | struct listnode *node; |
718e3744 | 790 | |
b2d7c082 | 791 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
1eb8ef25 | 792 | ripng_enable_apply (ifp); |
718e3744 | 793 | } |
6b0655a2 | 794 | |
a94434b6 | 795 | /* Clear all network and neighbor configuration */ |
796 | void | |
797 | ripng_clean_network () | |
798 | { | |
7a1d583c | 799 | unsigned int i; |
a94434b6 | 800 | char *str; |
801 | struct route_node *rn; | |
802 | ||
803 | /* ripng_enable_network */ | |
804 | for (rn = route_top (ripng_enable_network); rn; rn = route_next (rn)) | |
805 | if (rn->info) { | |
806 | rn->info = NULL; | |
807 | route_unlock_node(rn); | |
808 | } | |
809 | ||
810 | /* ripng_enable_if */ | |
55468c86 | 811 | for (i = 0; i < vector_active (ripng_enable_if); i++) |
a94434b6 | 812 | if ((str = vector_slot (ripng_enable_if, i)) != NULL) { |
813 | free (str); | |
814 | vector_slot (ripng_enable_if, i) = NULL; | |
815 | } | |
816 | } | |
6b0655a2 | 817 | |
718e3744 | 818 | /* Vector to store passive-interface name. */ |
819 | vector Vripng_passive_interface; | |
820 | ||
821 | /* Utility function for looking up passive interface settings. */ | |
6ac29a51 | 822 | static int |
98b718a9 | 823 | ripng_passive_interface_lookup (const char *ifname) |
718e3744 | 824 | { |
7a1d583c | 825 | unsigned int i; |
718e3744 | 826 | char *str; |
827 | ||
55468c86 | 828 | for (i = 0; i < vector_active (Vripng_passive_interface); i++) |
718e3744 | 829 | if ((str = vector_slot (Vripng_passive_interface, i)) != NULL) |
830 | if (strcmp (str, ifname) == 0) | |
831 | return i; | |
832 | return -1; | |
833 | } | |
834 | ||
835 | void | |
836 | ripng_passive_interface_apply (struct interface *ifp) | |
837 | { | |
838 | int ret; | |
839 | struct ripng_interface *ri; | |
840 | ||
841 | ri = ifp->info; | |
842 | ||
843 | ret = ripng_passive_interface_lookup (ifp->name); | |
844 | if (ret < 0) | |
845 | ri->passive = 0; | |
846 | else | |
847 | ri->passive = 1; | |
848 | } | |
849 | ||
6ac29a51 | 850 | static void |
718e3744 | 851 | ripng_passive_interface_apply_all (void) |
852 | { | |
853 | struct interface *ifp; | |
52dc7ee6 | 854 | struct listnode *node; |
718e3744 | 855 | |
b2d7c082 | 856 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
1eb8ef25 | 857 | ripng_passive_interface_apply (ifp); |
718e3744 | 858 | } |
859 | ||
860 | /* Passive interface. */ | |
6ac29a51 | 861 | static int |
98b718a9 | 862 | ripng_passive_interface_set (struct vty *vty, const char *ifname) |
718e3744 | 863 | { |
864 | if (ripng_passive_interface_lookup (ifname) >= 0) | |
865 | return CMD_WARNING; | |
866 | ||
867 | vector_set (Vripng_passive_interface, strdup (ifname)); | |
868 | ||
869 | ripng_passive_interface_apply_all (); | |
870 | ||
871 | return CMD_SUCCESS; | |
872 | } | |
873 | ||
6ac29a51 | 874 | static int |
98b718a9 | 875 | ripng_passive_interface_unset (struct vty *vty, const char *ifname) |
718e3744 | 876 | { |
877 | int i; | |
878 | char *str; | |
879 | ||
880 | i = ripng_passive_interface_lookup (ifname); | |
881 | if (i < 0) | |
882 | return CMD_WARNING; | |
883 | ||
884 | str = vector_slot (Vripng_passive_interface, i); | |
885 | free (str); | |
886 | vector_unset (Vripng_passive_interface, i); | |
887 | ||
888 | ripng_passive_interface_apply_all (); | |
889 | ||
890 | return CMD_SUCCESS; | |
891 | } | |
892 | ||
893 | /* Free all configured RIP passive-interface settings. */ | |
894 | void | |
895 | ripng_passive_interface_clean (void) | |
896 | { | |
7a1d583c | 897 | unsigned int i; |
718e3744 | 898 | char *str; |
899 | ||
55468c86 | 900 | for (i = 0; i < vector_active (Vripng_passive_interface); i++) |
718e3744 | 901 | if ((str = vector_slot (Vripng_passive_interface, i)) != NULL) |
902 | { | |
903 | free (str); | |
904 | vector_slot (Vripng_passive_interface, i) = NULL; | |
905 | } | |
906 | ripng_passive_interface_apply_all (); | |
907 | } | |
908 | ||
909 | /* Write RIPng enable network and interface to the vty. */ | |
910 | int | |
a94434b6 | 911 | ripng_network_write (struct vty *vty, int config_mode) |
718e3744 | 912 | { |
7a1d583c | 913 | unsigned int i; |
98b718a9 | 914 | const char *ifname; |
718e3744 | 915 | struct route_node *node; |
916 | char buf[BUFSIZ]; | |
917 | ||
918 | /* Write enable network. */ | |
919 | for (node = route_top (ripng_enable_network); node; node = route_next (node)) | |
920 | if (node->info) | |
921 | { | |
922 | struct prefix *p = &node->p; | |
a94434b6 | 923 | vty_out (vty, "%s%s/%d%s", |
924 | config_mode ? " network " : " ", | |
718e3744 | 925 | inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
926 | p->prefixlen, | |
927 | VTY_NEWLINE); | |
928 | ||
929 | } | |
930 | ||
931 | /* Write enable interface. */ | |
55468c86 | 932 | for (i = 0; i < vector_active (ripng_enable_if); i++) |
a94434b6 | 933 | if ((ifname = vector_slot (ripng_enable_if, i)) != NULL) |
934 | vty_out (vty, "%s%s%s", | |
935 | config_mode ? " network " : " ", | |
936 | ifname, | |
718e3744 | 937 | VTY_NEWLINE); |
938 | ||
939 | /* Write passive interface. */ | |
a94434b6 | 940 | if (config_mode) |
55468c86 | 941 | for (i = 0; i < vector_active (Vripng_passive_interface); i++) |
a94434b6 | 942 | if ((ifname = vector_slot (Vripng_passive_interface, i)) != NULL) |
943 | vty_out (vty, " passive-interface %s%s", ifname, VTY_NEWLINE); | |
718e3744 | 944 | |
945 | return 0; | |
946 | } | |
947 | ||
948 | /* RIPng enable on specified interface or matched network. */ | |
949 | DEFUN (ripng_network, | |
950 | ripng_network_cmd, | |
951 | "network IF_OR_ADDR", | |
952 | "RIPng enable on specified interface or network.\n" | |
953 | "Interface or address") | |
954 | { | |
ab34a28a | 955 | int idx_if_or_addr = 1; |
718e3744 | 956 | int ret; |
957 | struct prefix p; | |
958 | ||
ab34a28a | 959 | ret = str2prefix (argv[idx_if_or_addr]->arg, &p); |
718e3744 | 960 | |
961 | /* Given string is IPv6 network or interface name. */ | |
962 | if (ret) | |
963 | ret = ripng_enable_network_add (&p); | |
964 | else | |
ab34a28a | 965 | ret = ripng_enable_if_add (argv[idx_if_or_addr]->arg); |
718e3744 | 966 | |
967 | if (ret < 0) | |
968 | { | |
ab34a28a | 969 | vty_out (vty, "There is same network configuration %s%s", argv[idx_if_or_addr]->arg, |
718e3744 | 970 | VTY_NEWLINE); |
971 | return CMD_WARNING; | |
972 | } | |
973 | ||
718e3744 | 974 | return CMD_SUCCESS; |
975 | } | |
976 | ||
977 | /* RIPng enable on specified interface or matched network. */ | |
978 | DEFUN (no_ripng_network, | |
979 | no_ripng_network_cmd, | |
980 | "no network IF_OR_ADDR", | |
981 | NO_STR | |
982 | "RIPng enable on specified interface or network.\n" | |
983 | "Interface or address") | |
984 | { | |
ab34a28a | 985 | int idx_if_or_addr = 2; |
718e3744 | 986 | int ret; |
987 | struct prefix p; | |
988 | ||
ab34a28a | 989 | ret = str2prefix (argv[idx_if_or_addr]->arg, &p); |
718e3744 | 990 | |
991 | /* Given string is interface name. */ | |
992 | if (ret) | |
993 | ret = ripng_enable_network_delete (&p); | |
994 | else | |
ab34a28a | 995 | ret = ripng_enable_if_delete (argv[idx_if_or_addr]->arg); |
718e3744 | 996 | |
997 | if (ret < 0) | |
998 | { | |
ab34a28a | 999 | vty_out (vty, "can't find network %s%s", argv[idx_if_or_addr]->arg, |
718e3744 | 1000 | VTY_NEWLINE); |
1001 | return CMD_WARNING; | |
1002 | } | |
1003 | ||
a94434b6 | 1004 | return CMD_SUCCESS; |
1005 | } | |
1006 | ||
1007 | DEFUN (ipv6_ripng_split_horizon, | |
1008 | ipv6_ripng_split_horizon_cmd, | |
1009 | "ipv6 ripng split-horizon", | |
1010 | IPV6_STR | |
1011 | "Routing Information Protocol\n" | |
1012 | "Perform split horizon\n") | |
1013 | { | |
cdc2d765 | 1014 | VTY_DECLVAR_CONTEXT(interface, ifp); |
a94434b6 | 1015 | struct ripng_interface *ri; |
1016 | ||
a94434b6 | 1017 | ri = ifp->info; |
1018 | ||
1019 | ri->split_horizon = RIPNG_SPLIT_HORIZON; | |
1020 | return CMD_SUCCESS; | |
1021 | } | |
1022 | ||
1023 | DEFUN (ipv6_ripng_split_horizon_poisoned_reverse, | |
1024 | ipv6_ripng_split_horizon_poisoned_reverse_cmd, | |
1025 | "ipv6 ripng split-horizon poisoned-reverse", | |
1026 | IPV6_STR | |
1027 | "Routing Information Protocol\n" | |
1028 | "Perform split horizon\n" | |
1029 | "With poisoned-reverse\n") | |
1030 | { | |
cdc2d765 | 1031 | VTY_DECLVAR_CONTEXT(interface, ifp); |
a94434b6 | 1032 | struct ripng_interface *ri; |
1033 | ||
a94434b6 | 1034 | ri = ifp->info; |
1035 | ||
1036 | ri->split_horizon = RIPNG_SPLIT_HORIZON_POISONED_REVERSE; | |
1037 | return CMD_SUCCESS; | |
1038 | } | |
718e3744 | 1039 | |
a94434b6 | 1040 | DEFUN (no_ipv6_ripng_split_horizon, |
1041 | no_ipv6_ripng_split_horizon_cmd, | |
481af2ed | 1042 | "no ipv6 ripng split-horizon [poisoned-reverse]", |
a94434b6 | 1043 | NO_STR |
1044 | IPV6_STR | |
1045 | "Routing Information Protocol\n" | |
481af2ed QY |
1046 | "Perform split horizon\n" |
1047 | "With poisoned-reverse\n") | |
a94434b6 | 1048 | { |
cdc2d765 | 1049 | VTY_DECLVAR_CONTEXT(interface, ifp); |
a94434b6 | 1050 | struct ripng_interface *ri; |
1051 | ||
a94434b6 | 1052 | ri = ifp->info; |
1053 | ||
1054 | ri->split_horizon = RIPNG_NO_SPLIT_HORIZON; | |
718e3744 | 1055 | return CMD_SUCCESS; |
1056 | } | |
1057 | ||
1058 | DEFUN (ripng_passive_interface, | |
1059 | ripng_passive_interface_cmd, | |
1060 | "passive-interface IFNAME", | |
1061 | "Suppress routing updates on an interface\n" | |
1062 | "Interface name\n") | |
1063 | { | |
ab34a28a DW |
1064 | int idx_ifname = 1; |
1065 | return ripng_passive_interface_set (vty, argv[idx_ifname]->arg); | |
718e3744 | 1066 | } |
1067 | ||
1068 | DEFUN (no_ripng_passive_interface, | |
1069 | no_ripng_passive_interface_cmd, | |
1070 | "no passive-interface IFNAME", | |
1071 | NO_STR | |
1072 | "Suppress routing updates on an interface\n" | |
1073 | "Interface name\n") | |
1074 | { | |
ab34a28a DW |
1075 | int idx_ifname = 2; |
1076 | return ripng_passive_interface_unset (vty, argv[idx_ifname]->arg); | |
718e3744 | 1077 | } |
6b0655a2 | 1078 | |
6ac29a51 PJ |
1079 | static struct ripng_interface * |
1080 | ri_new (void) | |
718e3744 | 1081 | { |
1082 | struct ripng_interface *ri; | |
1083 | ri = XCALLOC (MTYPE_IF, sizeof (struct ripng_interface)); | |
a94434b6 | 1084 | |
1085 | /* Set default split-horizon behavior. If the interface is Frame | |
1086 | Relay or SMDS is enabled, the default value for split-horizon is | |
1087 | off. But currently Zebra does detect Frame Relay or SMDS | |
1088 | interface. So all interface is set to split horizon. */ | |
1089 | ri->split_horizon_default = RIPNG_SPLIT_HORIZON; | |
1090 | ri->split_horizon = ri->split_horizon_default; | |
1091 | ||
718e3744 | 1092 | return ri; |
1093 | } | |
1094 | ||
6ac29a51 | 1095 | static int |
718e3744 | 1096 | ripng_if_new_hook (struct interface *ifp) |
1097 | { | |
1098 | ifp->info = ri_new (); | |
1099 | return 0; | |
1100 | } | |
1101 | ||
a94434b6 | 1102 | /* Called when interface structure deleted. */ |
6ac29a51 | 1103 | static int |
a94434b6 | 1104 | ripng_if_delete_hook (struct interface *ifp) |
1105 | { | |
1106 | XFREE (MTYPE_IF, ifp->info); | |
1107 | ifp->info = NULL; | |
1108 | return 0; | |
1109 | } | |
1110 | ||
718e3744 | 1111 | /* Configuration write function for ripngd. */ |
6ac29a51 | 1112 | static int |
718e3744 | 1113 | interface_config_write (struct vty *vty) |
1114 | { | |
52dc7ee6 | 1115 | struct listnode *node; |
718e3744 | 1116 | struct interface *ifp; |
1117 | struct ripng_interface *ri; | |
1118 | int write = 0; | |
1119 | ||
b2d7c082 | 1120 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) |
718e3744 | 1121 | { |
718e3744 | 1122 | ri = ifp->info; |
1123 | ||
a94434b6 | 1124 | /* Do not display the interface if there is no |
1125 | * configuration about it. | |
1126 | **/ | |
1127 | if ((!ifp->desc) && | |
1128 | (ri->split_horizon == ri->split_horizon_default)) | |
1129 | continue; | |
1130 | ||
718e3744 | 1131 | vty_out (vty, "interface %s%s", ifp->name, |
1132 | VTY_NEWLINE); | |
1133 | if (ifp->desc) | |
1134 | vty_out (vty, " description %s%s", ifp->desc, | |
1135 | VTY_NEWLINE); | |
1136 | ||
a94434b6 | 1137 | /* Split horizon. */ |
1138 | if (ri->split_horizon != ri->split_horizon_default) | |
1139 | { | |
1140 | switch (ri->split_horizon) { | |
1141 | case RIPNG_SPLIT_HORIZON: | |
1142 | vty_out (vty, " ipv6 ripng split-horizon%s", VTY_NEWLINE); | |
1143 | break; | |
1144 | case RIPNG_SPLIT_HORIZON_POISONED_REVERSE: | |
1145 | vty_out (vty, " ipv6 ripng split-horizon poisoned-reverse%s", | |
1146 | VTY_NEWLINE); | |
1147 | break; | |
1148 | case RIPNG_NO_SPLIT_HORIZON: | |
1149 | default: | |
1150 | vty_out (vty, " no ipv6 ripng split-horizon%s", VTY_NEWLINE); | |
1151 | break; | |
1152 | } | |
1153 | } | |
1154 | ||
718e3744 | 1155 | vty_out (vty, "!%s", VTY_NEWLINE); |
1156 | ||
1157 | write++; | |
1158 | } | |
1159 | return write; | |
1160 | } | |
1161 | ||
1162 | /* ripngd's interface node. */ | |
7fc626de | 1163 | static struct cmd_node interface_node = |
718e3744 | 1164 | { |
1165 | INTERFACE_NODE, | |
1166 | "%s(config-if)# ", | |
a94434b6 | 1167 | 1 /* VTYSH */ |
718e3744 | 1168 | }; |
1169 | ||
1170 | /* Initialization of interface. */ | |
1171 | void | |
1172 | ripng_if_init () | |
1173 | { | |
1174 | /* Interface initialize. */ | |
718e3744 | 1175 | if_add_hook (IF_NEW_HOOK, ripng_if_new_hook); |
a94434b6 | 1176 | if_add_hook (IF_DELETE_HOOK, ripng_if_delete_hook); |
718e3744 | 1177 | |
1178 | /* RIPng enable network init. */ | |
1179 | ripng_enable_network = route_table_init (); | |
1180 | ||
1181 | /* RIPng enable interface init. */ | |
1182 | ripng_enable_if = vector_init (1); | |
1183 | ||
1184 | /* RIPng passive interface. */ | |
1185 | Vripng_passive_interface = vector_init (1); | |
1186 | ||
1187 | /* Install interface node. */ | |
1188 | install_node (&interface_node, interface_config_write); | |
0b84f294 | 1189 | if_cmd_init (); |
718e3744 | 1190 | |
1191 | install_element (RIPNG_NODE, &ripng_network_cmd); | |
1192 | install_element (RIPNG_NODE, &no_ripng_network_cmd); | |
1193 | install_element (RIPNG_NODE, &ripng_passive_interface_cmd); | |
1194 | install_element (RIPNG_NODE, &no_ripng_passive_interface_cmd); | |
a94434b6 | 1195 | |
1196 | install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd); | |
1197 | install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_poisoned_reverse_cmd); | |
1198 | install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_cmd); | |
718e3744 | 1199 | } |