paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Address linked list routine. |
| 3 | * Copyright (C) 1997, 98 Kunihiro Ishiguro |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | * 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "prefix.h" |
| 26 | #include "linklist.h" |
| 27 | #include "if.h" |
| 28 | #include "table.h" |
| 29 | #include "rib.h" |
| 30 | #include "table.h" |
| 31 | #include "log.h" |
paul | 0752ef0 | 2005-11-03 12:35:21 +0000 | [diff] [blame] | 32 | #include "memory.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 33 | |
| 34 | #include "zebra/zserv.h" |
| 35 | #include "zebra/redistribute.h" |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 36 | #include "zebra/interface.h" |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 37 | #include "zebra/connected.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 38 | |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 39 | /* withdraw a connected address */ |
| 40 | static void |
| 41 | connected_withdraw (struct connected *ifc) |
| 42 | { |
| 43 | if (! ifc) |
| 44 | return; |
| 45 | |
| 46 | /* Update interface address information to protocol daemon. */ |
| 47 | if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) |
| 48 | { |
| 49 | zebra_interface_address_delete_update (ifc->ifp, ifc); |
| 50 | |
| 51 | if_subnet_delete (ifc->ifp, ifc); |
| 52 | |
| 53 | if (ifc->address->family == AF_INET) |
| 54 | connected_down_ipv4 (ifc->ifp, ifc); |
vincent | aa2e32b | 2005-09-28 13:42:11 +0000 | [diff] [blame] | 55 | #ifdef HAVE_IPV6 |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 56 | else |
| 57 | connected_down_ipv6 (ifc->ifp, ifc); |
vincent | aa2e32b | 2005-09-28 13:42:11 +0000 | [diff] [blame] | 58 | #endif |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 59 | |
| 60 | UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL); |
| 61 | } |
| 62 | |
Andrew J. Schorr | 9c37851 | 2006-05-21 04:04:49 +0000 | [diff] [blame] | 63 | if (!CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) |
| 64 | { |
| 65 | listnode_delete (ifc->ifp->connected, ifc); |
| 66 | connected_free (ifc); |
| 67 | } |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static void |
| 71 | connected_announce (struct interface *ifp, struct connected *ifc) |
| 72 | { |
| 73 | if (!ifc) |
| 74 | return; |
| 75 | |
| 76 | listnode_add (ifp->connected, ifc); |
| 77 | |
| 78 | /* Update interface address information to protocol daemon. */ |
| 79 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) |
| 80 | { |
| 81 | if (ifc->address->family == AF_INET) |
| 82 | if_subnet_add (ifp, ifc); |
| 83 | |
| 84 | SET_FLAG (ifc->conf, ZEBRA_IFC_REAL); |
| 85 | |
| 86 | zebra_interface_address_add_update (ifp, ifc); |
| 87 | |
| 88 | if (if_is_up(ifp)) |
| 89 | { |
| 90 | if (ifc->address->family == AF_INET) |
| 91 | connected_up_ipv4 (ifp, ifc); |
vincent | aa2e32b | 2005-09-28 13:42:11 +0000 | [diff] [blame] | 92 | #ifdef HAVE_IPV6 |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 93 | else |
| 94 | connected_up_ipv6 (ifp, ifc); |
vincent | aa2e32b | 2005-09-28 13:42:11 +0000 | [diff] [blame] | 95 | #endif |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 100 | /* If same interface address is already exist... */ |
| 101 | struct connected * |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 102 | connected_check (struct interface *ifp, struct prefix *p) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 103 | { |
| 104 | struct connected *ifc; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 105 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 106 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 107 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc)) |
| 108 | if (prefix_same (ifc->address, p)) |
| 109 | return ifc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 110 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 111 | return NULL; |
| 112 | } |
| 113 | |
| 114 | /* Called from if_up(). */ |
| 115 | void |
| 116 | connected_up_ipv4 (struct interface *ifp, struct connected *ifc) |
| 117 | { |
| 118 | struct prefix_ipv4 p; |
| 119 | struct prefix_ipv4 *addr; |
| 120 | struct prefix_ipv4 *dest; |
| 121 | |
| 122 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) |
| 123 | return; |
| 124 | |
| 125 | addr = (struct prefix_ipv4 *) ifc->address; |
| 126 | dest = (struct prefix_ipv4 *) ifc->destination; |
| 127 | |
| 128 | memset (&p, 0, sizeof (struct prefix_ipv4)); |
| 129 | p.family = AF_INET; |
| 130 | p.prefixlen = addr->prefixlen; |
| 131 | |
| 132 | /* Point-to-point check. */ |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 133 | if (CONNECTED_POINTOPOINT_HOST(ifc)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 134 | p.prefix = dest->prefix; |
| 135 | else |
| 136 | p.prefix = addr->prefix; |
| 137 | |
| 138 | /* Apply mask to the network. */ |
| 139 | apply_mask_ipv4 (&p); |
| 140 | |
| 141 | /* In case of connected address is 0.0.0.0/0 we treat it tunnel |
| 142 | address. */ |
| 143 | if (prefix_ipv4_any (&p)) |
| 144 | return; |
| 145 | |
paul | c713300 | 2006-01-17 17:56:18 +0000 | [diff] [blame] | 146 | rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, |
| 147 | ifp->metric, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | |
| 149 | rib_update (); |
| 150 | } |
| 151 | |
| 152 | /* Add connected IPv4 route to the interface. */ |
| 153 | void |
| 154 | connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, |
paul | d06b2a6 | 2005-10-11 03:53:54 +0000 | [diff] [blame] | 155 | u_char prefixlen, struct in_addr *broad, |
| 156 | const char *label) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 157 | { |
| 158 | struct prefix_ipv4 *p; |
| 159 | struct connected *ifc; |
| 160 | struct connected *current; |
| 161 | |
| 162 | /* Make connected structure. */ |
| 163 | ifc = connected_new (); |
| 164 | ifc->ifp = ifp; |
| 165 | ifc->flags = flags; |
| 166 | |
| 167 | /* Allocate new connected address. */ |
| 168 | p = prefix_ipv4_new (); |
| 169 | p->family = AF_INET; |
| 170 | p->prefix = *addr; |
| 171 | p->prefixlen = prefixlen; |
| 172 | ifc->address = (struct prefix *) p; |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 173 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 174 | /* If there is broadcast or pointopoint address. */ |
| 175 | if (broad) |
| 176 | { |
| 177 | p = prefix_ipv4_new (); |
| 178 | p->family = AF_INET; |
| 179 | p->prefix = *broad; |
| 180 | ifc->destination = (struct prefix *) p; |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 181 | |
| 182 | /* validate the destination address */ |
| 183 | if (ifp->flags & IFF_POINTOPOINT) |
| 184 | { |
| 185 | if (IPV4_ADDR_SAME(addr,broad)) |
| 186 | zlog_warn("warning: PtP interface %s has same local and peer " |
| 187 | "address %s, routing protocols may malfunction", |
| 188 | ifp->name,inet_ntoa(*addr)); |
| 189 | else if ((prefixlen != IPV4_MAX_PREFIXLEN) && |
| 190 | (ipv4_network_addr(addr->s_addr,prefixlen) != |
| 191 | ipv4_network_addr(broad->s_addr,prefixlen))) |
| 192 | { |
| 193 | char buf[2][INET_ADDRSTRLEN]; |
| 194 | zlog_warn("warning: PtP interface %s network mismatch: local " |
| 195 | "%s/%d vs. peer %s, routing protocols may malfunction", |
| 196 | ifp->name, |
| 197 | inet_ntop (AF_INET, addr, buf[0], sizeof(buf[0])), |
| 198 | prefixlen, |
| 199 | inet_ntop (AF_INET, broad, buf[1], sizeof(buf[1]))); |
| 200 | } |
| 201 | } |
| 202 | else |
| 203 | { |
| 204 | if (broad->s_addr != ipv4_broadcast_addr(addr->s_addr,prefixlen)) |
| 205 | { |
| 206 | char buf[2][INET_ADDRSTRLEN]; |
| 207 | struct in_addr bcalc; |
| 208 | bcalc.s_addr = ipv4_broadcast_addr(addr->s_addr,prefixlen); |
| 209 | zlog_warn("warning: interface %s broadcast addr %s/%d != " |
| 210 | "calculated %s, routing protocols may malfunction", |
| 211 | ifp->name, |
| 212 | inet_ntop (AF_INET, broad, buf[0], sizeof(buf[0])), |
| 213 | prefixlen, |
| 214 | inet_ntop (AF_INET, &bcalc, buf[1], sizeof(buf[1]))); |
| 215 | } |
| 216 | } |
| 217 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 218 | } |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 219 | else |
| 220 | /* no broadcast or destination address was supplied */ |
ajs | 341a8f1 | 2004-12-22 16:32:16 +0000 | [diff] [blame] | 221 | if ((prefixlen == IPV4_MAX_PREFIXLEN) && if_is_pointopoint(ifp)) |
| 222 | zlog_warn("warning: PtP interface %s with addr %s/%d needs a " |
| 223 | "peer address",ifp->name,inet_ntoa(*addr),prefixlen); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 224 | |
| 225 | /* Label of this address. */ |
| 226 | if (label) |
paul | 0752ef0 | 2005-11-03 12:35:21 +0000 | [diff] [blame] | 227 | ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 228 | |
| 229 | /* Check same connected route. */ |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 230 | if ((current = connected_check (ifp, (struct prefix *) ifc->address))) |
Andrew J. Schorr | 0f38dc4 | 2006-05-19 13:53:23 +0000 | [diff] [blame] | 231 | { |
| 232 | if (CHECK_FLAG(current->conf, ZEBRA_IFC_CONFIGURED)) |
Andrew J. Schorr | 9c37851 | 2006-05-21 04:04:49 +0000 | [diff] [blame] | 233 | { |
| 234 | SET_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED); |
| 235 | UNSET_FLAG(current->conf, ZEBRA_IFC_CONFIGURED); |
| 236 | } |
Andrew J. Schorr | 0f38dc4 | 2006-05-19 13:53:23 +0000 | [diff] [blame] | 237 | connected_withdraw (current); /* implicit withdraw - freebsd does this */ |
| 238 | } |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 239 | |
| 240 | connected_announce (ifp, ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | void |
| 244 | connected_down_ipv4 (struct interface *ifp, struct connected *ifc) |
| 245 | { |
| 246 | struct prefix_ipv4 p; |
| 247 | struct prefix_ipv4 *addr; |
| 248 | struct prefix_ipv4 *dest; |
| 249 | |
| 250 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) |
| 251 | return; |
| 252 | |
| 253 | addr = (struct prefix_ipv4 *)ifc->address; |
| 254 | dest = (struct prefix_ipv4 *)ifc->destination; |
| 255 | |
| 256 | memset (&p, 0, sizeof (struct prefix_ipv4)); |
| 257 | p.family = AF_INET; |
| 258 | p.prefixlen = addr->prefixlen; |
| 259 | |
paul | 960182a | 2003-04-09 07:16:04 +0000 | [diff] [blame] | 260 | /* Point-to-point check. */ |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 261 | if (CONNECTED_POINTOPOINT_HOST(ifc)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 262 | p.prefix = dest->prefix; |
| 263 | else |
| 264 | p.prefix = addr->prefix; |
| 265 | |
| 266 | /* Apply mask to the network. */ |
| 267 | apply_mask_ipv4 (&p); |
| 268 | |
| 269 | /* In case of connected address is 0.0.0.0/0 we treat it tunnel |
| 270 | address. */ |
| 271 | if (prefix_ipv4_any (&p)) |
| 272 | return; |
| 273 | |
| 274 | rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0); |
| 275 | |
| 276 | rib_update (); |
| 277 | } |
| 278 | |
| 279 | /* Delete connected IPv4 route to the interface. */ |
| 280 | void |
| 281 | connected_delete_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, |
paul | 0752ef0 | 2005-11-03 12:35:21 +0000 | [diff] [blame] | 282 | u_char prefixlen, struct in_addr *broad) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 283 | { |
| 284 | struct prefix_ipv4 p; |
| 285 | struct connected *ifc; |
| 286 | |
| 287 | memset (&p, 0, sizeof (struct prefix_ipv4)); |
| 288 | p.family = AF_INET; |
| 289 | p.prefix = *addr; |
| 290 | p.prefixlen = prefixlen; |
| 291 | |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 292 | ifc = connected_check (ifp, (struct prefix *) &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 293 | if (! ifc) |
| 294 | return; |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 295 | |
| 296 | connected_withdraw (ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | #ifdef HAVE_IPV6 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 300 | void |
| 301 | connected_up_ipv6 (struct interface *ifp, struct connected *ifc) |
| 302 | { |
| 303 | struct prefix_ipv6 p; |
| 304 | struct prefix_ipv6 *addr; |
| 305 | struct prefix_ipv6 *dest; |
| 306 | |
| 307 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) |
| 308 | return; |
| 309 | |
| 310 | addr = (struct prefix_ipv6 *) ifc->address; |
| 311 | dest = (struct prefix_ipv6 *) ifc->destination; |
| 312 | |
| 313 | memset (&p, 0, sizeof (struct prefix_ipv6)); |
| 314 | p.family = AF_INET6; |
| 315 | p.prefixlen = addr->prefixlen; |
| 316 | |
paul | 31a476c | 2003-09-29 19:54:53 +0000 | [diff] [blame] | 317 | if (if_is_pointopoint (ifp) && dest) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 318 | { |
| 319 | if (IN6_IS_ADDR_UNSPECIFIED (&dest->prefix)) |
| 320 | p.prefix = addr->prefix; |
| 321 | else |
| 322 | p.prefix = dest->prefix; |
| 323 | } |
| 324 | else |
| 325 | p.prefix = addr->prefix; |
| 326 | |
| 327 | /* Apply mask to the network. */ |
| 328 | apply_mask_ipv6 (&p); |
| 329 | |
hasso | 726f9b2 | 2003-05-25 21:04:54 +0000 | [diff] [blame] | 330 | #if ! defined (MUSICA) && ! defined (LINUX) |
| 331 | /* XXX: It is already done by rib_bogus_ipv6 within rib_add_ipv6 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 332 | if (IN6_IS_ADDR_UNSPECIFIED (&p.prefix)) |
| 333 | return; |
hasso | 726f9b2 | 2003-05-25 21:04:54 +0000 | [diff] [blame] | 334 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 335 | |
paul | c713300 | 2006-01-17 17:56:18 +0000 | [diff] [blame] | 336 | rib_add_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, |
| 337 | ifp->metric, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 338 | |
| 339 | rib_update (); |
| 340 | } |
| 341 | |
| 342 | /* Add connected IPv6 route to the interface. */ |
| 343 | void |
| 344 | connected_add_ipv6 (struct interface *ifp, struct in6_addr *addr, |
paul | 89368d9 | 2005-11-26 09:14:07 +0000 | [diff] [blame] | 345 | u_char prefixlen, struct in6_addr *broad, |
| 346 | const char *label) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 347 | { |
| 348 | struct prefix_ipv6 *p; |
| 349 | struct connected *ifc; |
| 350 | struct connected *current; |
| 351 | |
| 352 | /* Make connected structure. */ |
| 353 | ifc = connected_new (); |
| 354 | ifc->ifp = ifp; |
| 355 | |
| 356 | /* Allocate new connected address. */ |
| 357 | p = prefix_ipv6_new (); |
| 358 | p->family = AF_INET6; |
| 359 | IPV6_ADDR_COPY (&p->prefix, addr); |
| 360 | p->prefixlen = prefixlen; |
| 361 | ifc->address = (struct prefix *) p; |
| 362 | |
| 363 | /* If there is broadcast or pointopoint address. */ |
| 364 | if (broad) |
| 365 | { |
| 366 | p = prefix_ipv6_new (); |
| 367 | p->family = AF_INET6; |
| 368 | IPV6_ADDR_COPY (&p->prefix, broad); |
| 369 | ifc->destination = (struct prefix *) p; |
| 370 | } |
| 371 | |
paul | 0752ef0 | 2005-11-03 12:35:21 +0000 | [diff] [blame] | 372 | /* Label of this address. */ |
| 373 | if (label) |
| 374 | ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); |
| 375 | |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 376 | if ((current = connected_check (ifp, (struct prefix *) ifc->address))) |
Andrew J. Schorr | 0f38dc4 | 2006-05-19 13:53:23 +0000 | [diff] [blame] | 377 | { |
| 378 | if (CHECK_FLAG(current->conf, ZEBRA_IFC_CONFIGURED)) |
Andrew J. Schorr | 9c37851 | 2006-05-21 04:04:49 +0000 | [diff] [blame] | 379 | { |
| 380 | SET_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED); |
| 381 | UNSET_FLAG(current->conf, ZEBRA_IFC_CONFIGURED); |
| 382 | } |
Andrew J. Schorr | 0f38dc4 | 2006-05-19 13:53:23 +0000 | [diff] [blame] | 383 | connected_withdraw (current); /* implicit update of existing address */ |
| 384 | } |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 385 | |
| 386 | connected_announce (ifp, ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | void |
| 390 | connected_down_ipv6 (struct interface *ifp, struct connected *ifc) |
| 391 | { |
| 392 | struct prefix_ipv6 p; |
| 393 | struct prefix_ipv6 *addr; |
| 394 | struct prefix_ipv6 *dest; |
| 395 | |
| 396 | if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) |
| 397 | return; |
| 398 | |
| 399 | addr = (struct prefix_ipv6 *) ifc->address; |
| 400 | dest = (struct prefix_ipv6 *) ifc->destination; |
| 401 | |
| 402 | memset (&p, 0, sizeof (struct prefix_ipv6)); |
| 403 | p.family = AF_INET6; |
| 404 | p.prefixlen = addr->prefixlen; |
| 405 | |
paul | 31a476c | 2003-09-29 19:54:53 +0000 | [diff] [blame] | 406 | if (if_is_pointopoint (ifp) && dest) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 407 | { |
| 408 | if (IN6_IS_ADDR_UNSPECIFIED (&dest->prefix)) |
| 409 | p.prefix = addr->prefix; |
| 410 | else |
| 411 | p.prefix = dest->prefix; |
| 412 | } |
| 413 | else |
| 414 | p.prefix = addr->prefix; |
| 415 | |
| 416 | apply_mask_ipv6 (&p); |
| 417 | |
| 418 | if (IN6_IS_ADDR_UNSPECIFIED (&p.prefix)) |
| 419 | return; |
| 420 | |
| 421 | rib_delete_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0); |
| 422 | |
| 423 | rib_update (); |
| 424 | } |
| 425 | |
| 426 | void |
| 427 | connected_delete_ipv6 (struct interface *ifp, struct in6_addr *address, |
hasso | fce954f | 2004-10-07 20:29:24 +0000 | [diff] [blame] | 428 | u_char prefixlen, struct in6_addr *broad) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 429 | { |
| 430 | struct prefix_ipv6 p; |
| 431 | struct connected *ifc; |
| 432 | |
| 433 | memset (&p, 0, sizeof (struct prefix_ipv6)); |
| 434 | p.family = AF_INET6; |
| 435 | memcpy (&p.prefix, address, sizeof (struct in6_addr)); |
| 436 | p.prefixlen = prefixlen; |
| 437 | |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 438 | ifc = connected_check (ifp, (struct prefix *) &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 439 | if (! ifc) |
| 440 | return; |
| 441 | |
paul | ca16218 | 2005-09-12 16:58:52 +0000 | [diff] [blame] | 442 | connected_withdraw (ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 443 | } |
| 444 | #endif /* HAVE_IPV6 */ |