paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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" |
gdt | 4d4653a | 2004-07-01 19:26:33 +0000 | [diff] [blame] | 37 | #include "privs.h" |
Feng Lu | 126215c | 2015-05-22 11:39:58 +0200 | [diff] [blame] | 38 | #include "vrf.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 39 | |
| 40 | #include "ripngd/ripngd.h" |
| 41 | #include "ripngd/ripng_debug.h" |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 42 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
gdt | 4d4653a | 2004-07-01 19:26:33 +0000 | [diff] [blame] | 51 | extern struct zebra_privs_t ripngd_privs; |
| 52 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 53 | /* Static utility function. */ |
| 54 | static void ripng_enable_apply (struct interface *); |
| 55 | static void ripng_passive_interface_apply (struct interface *); |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 59 | |
| 60 | /* Join to the all rip routers multicast group. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 61 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 62 | ripng_multicast_join (struct interface *ifp) |
| 63 | { |
| 64 | int ret; |
| 65 | struct ipv6_mreq mreq; |
ajs | 656b4ee | 2005-01-30 18:08:12 +0000 | [diff] [blame] | 66 | int save_errno; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 67 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 68 | if (if_is_up (ifp) && if_is_multicast (ifp)) { |
| 69 | memset (&mreq, 0, sizeof (mreq)); |
| 70 | inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); |
| 71 | mreq.ipv6mr_interface = ifp->ifindex; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | |
gdt | 4d4653a | 2004-07-01 19:26:33 +0000 | [diff] [blame] | 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 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 81 | ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, |
| 82 | (char *) &mreq, sizeof (mreq)); |
ajs | 656b4ee | 2005-01-30 18:08:12 +0000 | [diff] [blame] | 83 | save_errno = errno; |
gdt | ddf1c26 | 2004-01-04 01:02:55 +0000 | [diff] [blame] | 84 | |
gdt | 4d4653a | 2004-07-01 19:26:33 +0000 | [diff] [blame] | 85 | if (ripngd_privs.change (ZPRIVS_LOWER)) |
| 86 | zlog_err ("ripng_multicast_join: could not lower privs"); |
| 87 | |
ajs | 656b4ee | 2005-01-30 18:08:12 +0000 | [diff] [blame] | 88 | if (ret < 0 && save_errno == EADDRINUSE) |
gdt | ddf1c26 | 2004-01-04 01:02:55 +0000 | [diff] [blame] | 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 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 99 | if (ret < 0) |
ajs | 656b4ee | 2005-01-30 18:08:12 +0000 | [diff] [blame] | 100 | zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s", |
| 101 | safe_strerror (save_errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 102 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 103 | if (IS_RIPNG_DEBUG_EVENT) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 104 | zlog_debug ("RIPng %s join to all-rip-routers multicast group", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 105 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 106 | if (ret < 0) |
| 107 | return -1; |
| 108 | } |
| 109 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | /* Leave from the all rip routers multicast group. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 113 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 114 | ripng_multicast_leave (struct interface *ifp) |
| 115 | { |
| 116 | int ret; |
| 117 | struct ipv6_mreq mreq; |
| 118 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 119 | if (if_is_up (ifp) && if_is_multicast (ifp)) { |
| 120 | memset (&mreq, 0, sizeof (mreq)); |
| 121 | inet_pton(AF_INET6, RIPNG_GROUP, &mreq.ipv6mr_multiaddr); |
| 122 | mreq.ipv6mr_interface = ifp->ifindex; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 123 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 124 | ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, |
| 125 | (char *) &mreq, sizeof (mreq)); |
| 126 | if (ret < 0) |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 127 | zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", safe_strerror (errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 128 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 129 | if (IS_RIPNG_DEBUG_EVENT) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 130 | zlog_debug ("RIPng %s leave from all-rip-routers multicast group", |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 131 | ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 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 ? */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 141 | static int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 142 | ripng_if_ipv6_lladdress_check (struct interface *ifp) |
| 143 | { |
| 144 | struct listnode *nn; |
| 145 | struct connected *connected; |
| 146 | int count = 0; |
| 147 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 148 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected)) |
| 149 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 150 | struct prefix *p; |
| 151 | p = connected->address; |
| 152 | |
| 153 | if ((p->family == AF_INET6) && |
| 154 | IN6_IS_ADDR_LINKLOCAL (&p->u.prefix6)) |
| 155 | count++; |
| 156 | } |
| 157 | |
| 158 | return count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 161 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 162 | ripng_if_down (struct interface *ifp) |
| 163 | { |
| 164 | struct route_node *rp; |
| 165 | struct ripng_info *rinfo; |
| 166 | struct ripng_interface *ri; |
Feng Lu | e97c31a | 2015-05-22 11:39:53 +0200 | [diff] [blame] | 167 | struct list *list = NULL; |
| 168 | struct listnode *listnode = NULL, *nextnode = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 169 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 170 | if (ripng) |
Feng Lu | e97c31a | 2015-05-22 11:39:53 +0200 | [diff] [blame] | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 176 | |
| 177 | ri = ifp->info; |
| 178 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 179 | if (ri->running) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 180 | { |
| 181 | if (IS_RIPNG_DEBUG_EVENT) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 182 | zlog_debug ("turn off %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 195 | ripng_interface_up (int command, struct zclient *zclient, zebra_size_t length, |
| 196 | vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 197 | { |
| 198 | struct stream *s; |
| 199 | struct interface *ifp; |
| 200 | |
| 201 | /* zebra_interface_state_read() updates interface structure in iflist. */ |
| 202 | s = zclient->ibuf; |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 203 | ifp = zebra_interface_state_read (s, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 204 | |
| 205 | if (ifp == NULL) |
| 206 | return 0; |
| 207 | |
| 208 | if (IS_RIPNG_DEBUG_ZEBRA) |
Stephen Hemminger | 30d2059 | 2009-07-28 11:58:51 +0100 | [diff] [blame] | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 228 | zebra_size_t length, vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 229 | { |
| 230 | struct stream *s; |
| 231 | struct interface *ifp; |
| 232 | |
| 233 | /* zebra_interface_state_read() updates interface structure in iflist. */ |
| 234 | s = zclient->ibuf; |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 235 | ifp = zebra_interface_state_read (s, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 236 | |
| 237 | if (ifp == NULL) |
| 238 | return 0; |
| 239 | |
| 240 | ripng_if_down (ifp); |
| 241 | |
| 242 | if (IS_RIPNG_DEBUG_ZEBRA) |
Stephen Hemminger | 5eb9d11 | 2009-12-10 15:52:33 +0300 | [diff] [blame] | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 246 | |
| 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | /* Inteface addition message from zebra. */ |
| 251 | int |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 252 | ripng_interface_add (int command, struct zclient *zclient, zebra_size_t length, |
| 253 | vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 254 | { |
| 255 | struct interface *ifp; |
| 256 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 257 | ifp = zebra_interface_add_read (zclient->ibuf, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 258 | |
| 259 | if (IS_RIPNG_DEBUG_ZEBRA) |
Stephen Hemminger | 5eb9d11 | 2009-12-10 15:52:33 +0300 | [diff] [blame] | 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); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 278 | zebra_size_t length, vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 279 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 280 | struct interface *ifp; |
| 281 | struct stream *s; |
| 282 | |
| 283 | s = zclient->ibuf; |
| 284 | /* zebra_interface_state_read() updates interface structure in iflist */ |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 285 | ifp = zebra_interface_state_read (s, vrf_id); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 286 | |
| 287 | if (ifp == NULL) |
| 288 | return 0; |
| 289 | |
| 290 | if (if_is_up (ifp)) { |
| 291 | ripng_if_down(ifp); |
| 292 | } |
| 293 | |
Stephen Hemminger | 5eb9d11 | 2009-12-10 15:52:33 +0300 | [diff] [blame] | 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); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 297 | |
| 298 | /* To support pseudo interface do not free interface structure. */ |
| 299 | /* if_delete(ifp); */ |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 300 | ifp->ifindex = IFINDEX_INTERNAL; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 301 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 302 | return 0; |
| 303 | } |
| 304 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 305 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 306 | ripng_interface_clean (void) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 307 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 308 | struct listnode *node, *nnode; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 309 | struct interface *ifp; |
| 310 | struct ripng_interface *ri; |
| 311 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 312 | for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp)) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 313 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 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 |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 329 | ripng_interface_reset (void) |
| 330 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 331 | struct listnode *node; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 332 | struct interface *ifp; |
| 333 | struct ripng_interface *ri; |
| 334 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 335 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 336 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 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, |
| 386 | &address, ifc->ifp->ifindex, NULL); |
| 387 | |
| 388 | } |
| 389 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 390 | int |
| 391 | ripng_interface_address_add (int command, struct zclient *zclient, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 392 | zebra_size_t length, vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 393 | { |
| 394 | struct connected *c; |
| 395 | struct prefix *p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 396 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 397 | c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 398 | zclient->ibuf, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 399 | |
| 400 | if (c == NULL) |
| 401 | return 0; |
| 402 | |
| 403 | p = c->address; |
| 404 | |
| 405 | if (p->family == AF_INET6) |
| 406 | { |
Paul Jakma | 995b965 | 2006-05-11 13:20:47 +0000 | [diff] [blame] | 407 | struct ripng_interface *ri = c->ifp->info; |
| 408 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 409 | if (IS_RIPNG_DEBUG_ZEBRA) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 410 | zlog_debug ("RIPng connected address %s/%d add", |
hasso | 3a2ce6a | 2005-04-08 01:30:51 +0000 | [diff] [blame] | 411 | inet6_ntoa(p->u.prefix6), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 412 | p->prefixlen); |
| 413 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 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 */ |
Paul Jakma | 995b965 | 2006-05-11 13:20:47 +0000 | [diff] [blame] | 418 | if (!ri->running) { |
| 419 | /* Check if this interface is RIP enabled or not.*/ |
| 420 | ripng_enable_apply (c->ifp); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 421 | |
Paul Jakma | 995b965 | 2006-05-11 13:20:47 +0000 | [diff] [blame] | 422 | /* Apply distribute list to the interface. */ |
| 423 | ripng_distribute_update_interface (c->ifp); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 424 | |
Paul Jakma | 995b965 | 2006-05-11 13:20:47 +0000 | [diff] [blame] | 425 | /* Check interface routemap. */ |
| 426 | ripng_if_rmap_update_interface (c->ifp); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 427 | } |
| 428 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | return 0; |
| 432 | } |
| 433 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 457 | int |
| 458 | ripng_interface_address_delete (int command, struct zclient *zclient, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 459 | zebra_size_t length, vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 460 | { |
| 461 | struct connected *ifc; |
| 462 | struct prefix *p; |
| 463 | char buf[INET6_ADDRSTRLEN]; |
| 464 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 465 | ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 466 | zclient->ibuf, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 467 | |
| 468 | if (ifc) |
| 469 | { |
| 470 | p = ifc->address; |
| 471 | |
| 472 | if (p->family == AF_INET6) |
| 473 | { |
| 474 | if (IS_RIPNG_DEBUG_ZEBRA) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 475 | zlog_debug ("RIPng connected address %s/%d delete", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 476 | inet_ntop (AF_INET6, &p->u.prefix6, buf, |
| 477 | INET6_ADDRSTRLEN), |
| 478 | p->prefixlen); |
| 479 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 480 | /* Check wether this prefix needs to be removed. */ |
| 481 | ripng_apply_address_del(ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 482 | } |
| 483 | connected_free (ifc); |
| 484 | } |
| 485 | |
| 486 | return 0; |
| 487 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 488 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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. */ |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 496 | /* Check wether the interface has at least a connected prefix that |
| 497 | * is within the ripng_enable_network table. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 498 | static int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 499 | ripng_enable_network_lookup_if (struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 500 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 501 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 502 | struct connected *connected; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 503 | struct prefix_ipv6 address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 504 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 505 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) |
| 506 | { |
| 507 | struct prefix *p; |
| 508 | struct route_node *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 509 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 510 | p = connected->address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 512 | if (p->family == AF_INET6) |
| 513 | { |
| 514 | address.family = AF_INET6; |
| 515 | address.prefix = p->u.prefix6; |
| 516 | address.prefixlen = IPV6_MAX_BITLEN; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 517 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 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 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 527 | return -1; |
| 528 | } |
| 529 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 530 | /* Check wether connected is within the ripng_enable_network table. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 531 | static int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 559 | /* Add RIPng enable network. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 560 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 573 | node->info = (char *) "enabled"; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 574 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 575 | /* XXX: One should find a better solution than a generic one */ |
| 576 | ripng_enable_apply_all(); |
| 577 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 578 | return 1; |
| 579 | } |
| 580 | |
| 581 | /* Delete RIPng enable network. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 582 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 604 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 605 | ripng_enable_if_lookup (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 606 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 607 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 608 | char *str; |
| 609 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 610 | for (i = 0; i < vector_active (ripng_enable_if); i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 618 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 619 | ripng_enable_if_add (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 629 | ripng_enable_apply_all(); |
| 630 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 631 | return 1; |
| 632 | } |
| 633 | |
| 634 | /* Delete interface from ripng_enable_if. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 635 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 636 | ripng_enable_if_delete (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 649 | ripng_enable_apply_all(); |
| 650 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 651 | return 1; |
| 652 | } |
| 653 | |
| 654 | /* Wake up interface. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 655 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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. */ |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 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; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 675 | |
| 676 | /* Send RIP request to the interface. */ |
| 677 | ripng_request (ifp); |
| 678 | |
| 679 | return 0; |
| 680 | } |
| 681 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 682 | static void |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 683 | ripng_connect_set (struct interface *ifp, int set) |
| 684 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 685 | struct listnode *node, *nnode; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 686 | struct connected *connected; |
| 687 | struct prefix_ipv6 address; |
| 688 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 689 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected)) |
| 690 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 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, |
| 707 | &address, connected->ifp->ifindex, NULL); |
| 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, |
| 713 | &address, connected->ifp->ifindex, NULL); |
| 714 | } |
| 715 | } |
| 716 | } |
| 717 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 726 | if (! if_is_up (ifp)) |
| 727 | return; |
| 728 | |
| 729 | ri = ifp->info; |
| 730 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 731 | /* Is this interface a candidate for RIPng ? */ |
| 732 | ret = ripng_enable_network_lookup_if (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 756 | /* Update running status of the interface. */ |
| 757 | if (ri->enable_network || ri->enable_interface) |
| 758 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 759 | { |
| 760 | if (IS_RIPNG_DEBUG_EVENT) |
ajs | 2e23ab2 | 2004-12-08 19:46:50 +0000 | [diff] [blame] | 761 | zlog_debug ("RIPng turn on %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 762 | |
| 763 | /* Add interface wake up thread. */ |
| 764 | if (! ri->t_wakeup) |
| 765 | ri->t_wakeup = thread_add_timer (master, ripng_interface_wakeup, |
| 766 | ifp, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 767 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 768 | ripng_connect_set (ifp, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 769 | } |
| 770 | } |
| 771 | else |
| 772 | { |
| 773 | if (ri->running) |
| 774 | { |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 775 | /* Might as well clean up the route table as well |
| 776 | * ripng_if_down sets to 0 ri->running, and displays "turn off %s" |
| 777 | **/ |
| 778 | ripng_if_down(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 779 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 780 | ripng_connect_set (ifp, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 781 | } |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | /* Set distribute list to all interfaces. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 786 | static void |
| 787 | ripng_enable_apply_all (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 788 | { |
| 789 | struct interface *ifp; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 790 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 791 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 792 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 793 | ripng_enable_apply (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 794 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 795 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 796 | /* Clear all network and neighbor configuration */ |
| 797 | void |
| 798 | ripng_clean_network () |
| 799 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 800 | unsigned int i; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 801 | char *str; |
| 802 | struct route_node *rn; |
| 803 | |
| 804 | /* ripng_enable_network */ |
| 805 | for (rn = route_top (ripng_enable_network); rn; rn = route_next (rn)) |
| 806 | if (rn->info) { |
| 807 | rn->info = NULL; |
| 808 | route_unlock_node(rn); |
| 809 | } |
| 810 | |
| 811 | /* ripng_enable_if */ |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 812 | for (i = 0; i < vector_active (ripng_enable_if); i++) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 813 | if ((str = vector_slot (ripng_enable_if, i)) != NULL) { |
| 814 | free (str); |
| 815 | vector_slot (ripng_enable_if, i) = NULL; |
| 816 | } |
| 817 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 818 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 819 | /* Vector to store passive-interface name. */ |
| 820 | vector Vripng_passive_interface; |
| 821 | |
| 822 | /* Utility function for looking up passive interface settings. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 823 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 824 | ripng_passive_interface_lookup (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 825 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 826 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 827 | char *str; |
| 828 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 829 | for (i = 0; i < vector_active (Vripng_passive_interface); i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 830 | if ((str = vector_slot (Vripng_passive_interface, i)) != NULL) |
| 831 | if (strcmp (str, ifname) == 0) |
| 832 | return i; |
| 833 | return -1; |
| 834 | } |
| 835 | |
| 836 | void |
| 837 | ripng_passive_interface_apply (struct interface *ifp) |
| 838 | { |
| 839 | int ret; |
| 840 | struct ripng_interface *ri; |
| 841 | |
| 842 | ri = ifp->info; |
| 843 | |
| 844 | ret = ripng_passive_interface_lookup (ifp->name); |
| 845 | if (ret < 0) |
| 846 | ri->passive = 0; |
| 847 | else |
| 848 | ri->passive = 1; |
| 849 | } |
| 850 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 851 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 852 | ripng_passive_interface_apply_all (void) |
| 853 | { |
| 854 | struct interface *ifp; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 855 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 856 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 857 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 858 | ripng_passive_interface_apply (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | /* Passive interface. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 862 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 863 | ripng_passive_interface_set (struct vty *vty, const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 864 | { |
| 865 | if (ripng_passive_interface_lookup (ifname) >= 0) |
| 866 | return CMD_WARNING; |
| 867 | |
| 868 | vector_set (Vripng_passive_interface, strdup (ifname)); |
| 869 | |
| 870 | ripng_passive_interface_apply_all (); |
| 871 | |
| 872 | return CMD_SUCCESS; |
| 873 | } |
| 874 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 875 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 876 | ripng_passive_interface_unset (struct vty *vty, const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 877 | { |
| 878 | int i; |
| 879 | char *str; |
| 880 | |
| 881 | i = ripng_passive_interface_lookup (ifname); |
| 882 | if (i < 0) |
| 883 | return CMD_WARNING; |
| 884 | |
| 885 | str = vector_slot (Vripng_passive_interface, i); |
| 886 | free (str); |
| 887 | vector_unset (Vripng_passive_interface, i); |
| 888 | |
| 889 | ripng_passive_interface_apply_all (); |
| 890 | |
| 891 | return CMD_SUCCESS; |
| 892 | } |
| 893 | |
| 894 | /* Free all configured RIP passive-interface settings. */ |
| 895 | void |
| 896 | ripng_passive_interface_clean (void) |
| 897 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 898 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 899 | char *str; |
| 900 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 901 | for (i = 0; i < vector_active (Vripng_passive_interface); i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 902 | if ((str = vector_slot (Vripng_passive_interface, i)) != NULL) |
| 903 | { |
| 904 | free (str); |
| 905 | vector_slot (Vripng_passive_interface, i) = NULL; |
| 906 | } |
| 907 | ripng_passive_interface_apply_all (); |
| 908 | } |
| 909 | |
| 910 | /* Write RIPng enable network and interface to the vty. */ |
| 911 | int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 912 | ripng_network_write (struct vty *vty, int config_mode) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 913 | { |
hasso | 7a1d583 | 2004-10-08 06:32:23 +0000 | [diff] [blame] | 914 | unsigned int i; |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 915 | const char *ifname; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 916 | struct route_node *node; |
| 917 | char buf[BUFSIZ]; |
| 918 | |
| 919 | /* Write enable network. */ |
| 920 | for (node = route_top (ripng_enable_network); node; node = route_next (node)) |
| 921 | if (node->info) |
| 922 | { |
| 923 | struct prefix *p = &node->p; |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 924 | vty_out (vty, "%s%s/%d%s", |
| 925 | config_mode ? " network " : " ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 926 | inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), |
| 927 | p->prefixlen, |
| 928 | VTY_NEWLINE); |
| 929 | |
| 930 | } |
| 931 | |
| 932 | /* Write enable interface. */ |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 933 | for (i = 0; i < vector_active (ripng_enable_if); i++) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 934 | if ((ifname = vector_slot (ripng_enable_if, i)) != NULL) |
| 935 | vty_out (vty, "%s%s%s", |
| 936 | config_mode ? " network " : " ", |
| 937 | ifname, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 938 | VTY_NEWLINE); |
| 939 | |
| 940 | /* Write passive interface. */ |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 941 | if (config_mode) |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 942 | for (i = 0; i < vector_active (Vripng_passive_interface); i++) |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 943 | if ((ifname = vector_slot (Vripng_passive_interface, i)) != NULL) |
| 944 | vty_out (vty, " passive-interface %s%s", ifname, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 945 | |
| 946 | return 0; |
| 947 | } |
| 948 | |
| 949 | /* RIPng enable on specified interface or matched network. */ |
| 950 | DEFUN (ripng_network, |
| 951 | ripng_network_cmd, |
| 952 | "network IF_OR_ADDR", |
| 953 | "RIPng enable on specified interface or network.\n" |
| 954 | "Interface or address") |
| 955 | { |
| 956 | int ret; |
| 957 | struct prefix p; |
| 958 | |
| 959 | ret = str2prefix (argv[0], &p); |
| 960 | |
| 961 | /* Given string is IPv6 network or interface name. */ |
| 962 | if (ret) |
| 963 | ret = ripng_enable_network_add (&p); |
| 964 | else |
| 965 | ret = ripng_enable_if_add (argv[0]); |
| 966 | |
| 967 | if (ret < 0) |
| 968 | { |
| 969 | vty_out (vty, "There is same network configuration %s%s", argv[0], |
| 970 | VTY_NEWLINE); |
| 971 | return CMD_WARNING; |
| 972 | } |
| 973 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | { |
| 985 | int ret; |
| 986 | struct prefix p; |
| 987 | |
| 988 | ret = str2prefix (argv[0], &p); |
| 989 | |
| 990 | /* Given string is interface name. */ |
| 991 | if (ret) |
| 992 | ret = ripng_enable_network_delete (&p); |
| 993 | else |
| 994 | ret = ripng_enable_if_delete (argv[0]); |
| 995 | |
| 996 | if (ret < 0) |
| 997 | { |
| 998 | vty_out (vty, "can't find network %s%s", argv[0], |
| 999 | VTY_NEWLINE); |
| 1000 | return CMD_WARNING; |
| 1001 | } |
| 1002 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1003 | return CMD_SUCCESS; |
| 1004 | } |
| 1005 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1006 | DEFUN (ipv6_ripng_split_horizon, |
| 1007 | ipv6_ripng_split_horizon_cmd, |
| 1008 | "ipv6 ripng split-horizon", |
| 1009 | IPV6_STR |
| 1010 | "Routing Information Protocol\n" |
| 1011 | "Perform split horizon\n") |
| 1012 | { |
| 1013 | struct interface *ifp; |
| 1014 | struct ripng_interface *ri; |
| 1015 | |
| 1016 | ifp = vty->index; |
| 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 | { |
| 1031 | struct interface *ifp; |
| 1032 | struct ripng_interface *ri; |
| 1033 | |
| 1034 | ifp = vty->index; |
| 1035 | ri = ifp->info; |
| 1036 | |
| 1037 | ri->split_horizon = RIPNG_SPLIT_HORIZON_POISONED_REVERSE; |
| 1038 | return CMD_SUCCESS; |
| 1039 | } |
| 1040 | |
| 1041 | DEFUN (no_ipv6_ripng_split_horizon, |
| 1042 | no_ipv6_ripng_split_horizon_cmd, |
| 1043 | "no ipv6 ripng split-horizon", |
| 1044 | NO_STR |
| 1045 | IPV6_STR |
| 1046 | "Routing Information Protocol\n" |
| 1047 | "Perform split horizon\n") |
| 1048 | { |
| 1049 | struct interface *ifp; |
| 1050 | struct ripng_interface *ri; |
| 1051 | |
| 1052 | ifp = vty->index; |
| 1053 | ri = ifp->info; |
| 1054 | |
| 1055 | ri->split_horizon = RIPNG_NO_SPLIT_HORIZON; |
| 1056 | return CMD_SUCCESS; |
| 1057 | } |
| 1058 | |
| 1059 | ALIAS (no_ipv6_ripng_split_horizon, |
| 1060 | no_ipv6_ripng_split_horizon_poisoned_reverse_cmd, |
| 1061 | "no ipv6 ripng split-horizon poisoned-reverse", |
| 1062 | NO_STR |
| 1063 | IPV6_STR |
| 1064 | "Routing Information Protocol\n" |
| 1065 | "Perform split horizon\n" |
| 1066 | "With poisoned-reverse\n") |
| 1067 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1068 | DEFUN (ripng_passive_interface, |
| 1069 | ripng_passive_interface_cmd, |
| 1070 | "passive-interface IFNAME", |
| 1071 | "Suppress routing updates on an interface\n" |
| 1072 | "Interface name\n") |
| 1073 | { |
| 1074 | return ripng_passive_interface_set (vty, argv[0]); |
| 1075 | } |
| 1076 | |
| 1077 | DEFUN (no_ripng_passive_interface, |
| 1078 | no_ripng_passive_interface_cmd, |
| 1079 | "no passive-interface IFNAME", |
| 1080 | NO_STR |
| 1081 | "Suppress routing updates on an interface\n" |
| 1082 | "Interface name\n") |
| 1083 | { |
| 1084 | return ripng_passive_interface_unset (vty, argv[0]); |
| 1085 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1086 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1087 | static struct ripng_interface * |
| 1088 | ri_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1089 | { |
| 1090 | struct ripng_interface *ri; |
| 1091 | ri = XCALLOC (MTYPE_IF, sizeof (struct ripng_interface)); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1092 | |
| 1093 | /* Set default split-horizon behavior. If the interface is Frame |
| 1094 | Relay or SMDS is enabled, the default value for split-horizon is |
| 1095 | off. But currently Zebra does detect Frame Relay or SMDS |
| 1096 | interface. So all interface is set to split horizon. */ |
| 1097 | ri->split_horizon_default = RIPNG_SPLIT_HORIZON; |
| 1098 | ri->split_horizon = ri->split_horizon_default; |
| 1099 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1100 | return ri; |
| 1101 | } |
| 1102 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1103 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1104 | ripng_if_new_hook (struct interface *ifp) |
| 1105 | { |
| 1106 | ifp->info = ri_new (); |
| 1107 | return 0; |
| 1108 | } |
| 1109 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1110 | /* Called when interface structure deleted. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1111 | static int |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1112 | ripng_if_delete_hook (struct interface *ifp) |
| 1113 | { |
| 1114 | XFREE (MTYPE_IF, ifp->info); |
| 1115 | ifp->info = NULL; |
| 1116 | return 0; |
| 1117 | } |
| 1118 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1119 | /* Configuration write function for ripngd. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 1120 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1121 | interface_config_write (struct vty *vty) |
| 1122 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1123 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1124 | struct interface *ifp; |
| 1125 | struct ripng_interface *ri; |
| 1126 | int write = 0; |
| 1127 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1128 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1129 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1130 | ri = ifp->info; |
| 1131 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1132 | /* Do not display the interface if there is no |
| 1133 | * configuration about it. |
| 1134 | **/ |
| 1135 | if ((!ifp->desc) && |
| 1136 | (ri->split_horizon == ri->split_horizon_default)) |
| 1137 | continue; |
| 1138 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1139 | vty_out (vty, "interface %s%s", ifp->name, |
| 1140 | VTY_NEWLINE); |
| 1141 | if (ifp->desc) |
| 1142 | vty_out (vty, " description %s%s", ifp->desc, |
| 1143 | VTY_NEWLINE); |
| 1144 | |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1145 | /* Split horizon. */ |
| 1146 | if (ri->split_horizon != ri->split_horizon_default) |
| 1147 | { |
| 1148 | switch (ri->split_horizon) { |
| 1149 | case RIPNG_SPLIT_HORIZON: |
| 1150 | vty_out (vty, " ipv6 ripng split-horizon%s", VTY_NEWLINE); |
| 1151 | break; |
| 1152 | case RIPNG_SPLIT_HORIZON_POISONED_REVERSE: |
| 1153 | vty_out (vty, " ipv6 ripng split-horizon poisoned-reverse%s", |
| 1154 | VTY_NEWLINE); |
| 1155 | break; |
| 1156 | case RIPNG_NO_SPLIT_HORIZON: |
| 1157 | default: |
| 1158 | vty_out (vty, " no ipv6 ripng split-horizon%s", VTY_NEWLINE); |
| 1159 | break; |
| 1160 | } |
| 1161 | } |
| 1162 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1163 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 1164 | |
| 1165 | write++; |
| 1166 | } |
| 1167 | return write; |
| 1168 | } |
| 1169 | |
| 1170 | /* ripngd's interface node. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 1171 | static struct cmd_node interface_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1172 | { |
| 1173 | INTERFACE_NODE, |
| 1174 | "%s(config-if)# ", |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1175 | 1 /* VTYSH */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1176 | }; |
| 1177 | |
| 1178 | /* Initialization of interface. */ |
| 1179 | void |
| 1180 | ripng_if_init () |
| 1181 | { |
| 1182 | /* Interface initialize. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1183 | if_add_hook (IF_NEW_HOOK, ripng_if_new_hook); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1184 | if_add_hook (IF_DELETE_HOOK, ripng_if_delete_hook); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1185 | |
| 1186 | /* RIPng enable network init. */ |
| 1187 | ripng_enable_network = route_table_init (); |
| 1188 | |
| 1189 | /* RIPng enable interface init. */ |
| 1190 | ripng_enable_if = vector_init (1); |
| 1191 | |
| 1192 | /* RIPng passive interface. */ |
| 1193 | Vripng_passive_interface = vector_init (1); |
| 1194 | |
| 1195 | /* Install interface node. */ |
| 1196 | install_node (&interface_node, interface_config_write); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1197 | |
| 1198 | /* Install commands. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1199 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 1200 | install_element (CONFIG_NODE, &no_interface_cmd); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1201 | install_default (INTERFACE_NODE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1202 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 1203 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 1204 | |
| 1205 | install_element (RIPNG_NODE, &ripng_network_cmd); |
| 1206 | install_element (RIPNG_NODE, &no_ripng_network_cmd); |
| 1207 | install_element (RIPNG_NODE, &ripng_passive_interface_cmd); |
| 1208 | install_element (RIPNG_NODE, &no_ripng_passive_interface_cmd); |
hasso | a94434b | 2003-05-25 17:10:12 +0000 | [diff] [blame] | 1209 | |
| 1210 | install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_cmd); |
| 1211 | install_element (INTERFACE_NODE, &ipv6_ripng_split_horizon_poisoned_reverse_cmd); |
| 1212 | install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_cmd); |
| 1213 | install_element (INTERFACE_NODE, &no_ipv6_ripng_split_horizon_poisoned_reverse_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1214 | } |