paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* Redistribution Handler |
| 2 | * Copyright (C) 1998 Kunihiro Ishiguro |
| 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | * 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "vector.h" |
| 25 | #include "vty.h" |
| 26 | #include "command.h" |
| 27 | #include "prefix.h" |
| 28 | #include "table.h" |
| 29 | #include "stream.h" |
| 30 | #include "zclient.h" |
| 31 | #include "linklist.h" |
| 32 | #include "log.h" |
Feng Lu | 41f44a2 | 2015-05-22 11:39:56 +0200 | [diff] [blame] | 33 | #include "vrf.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 34 | |
| 35 | #include "zebra/rib.h" |
| 36 | #include "zebra/zserv.h" |
| 37 | #include "zebra/redistribute.h" |
| 38 | #include "zebra/debug.h" |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 39 | #include "zebra/router-id.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 40 | |
paul | b21b19c | 2003-06-15 01:28:29 +0000 | [diff] [blame] | 41 | /* master zebra server structure */ |
| 42 | extern struct zebra_t zebrad; |
| 43 | |
Paul Jakma | 6dc686a | 2007-04-10 19:24:45 +0000 | [diff] [blame] | 44 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 45 | zebra_check_addr (struct prefix *p) |
| 46 | { |
| 47 | if (p->family == AF_INET) |
| 48 | { |
| 49 | u_int32_t addr; |
| 50 | |
| 51 | addr = p->u.prefix4.s_addr; |
| 52 | addr = ntohl (addr); |
| 53 | |
Paul Jakma | 6dc686a | 2007-04-10 19:24:45 +0000 | [diff] [blame] | 54 | if (IPV4_NET127 (addr) |
| 55 | || IN_CLASSD (addr) |
| 56 | || IPV4_LINKLOCAL(addr)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 57 | return 0; |
| 58 | } |
| 59 | #ifdef HAVE_IPV6 |
| 60 | if (p->family == AF_INET6) |
| 61 | { |
| 62 | if (IN6_IS_ADDR_LOOPBACK (&p->u.prefix6)) |
| 63 | return 0; |
| 64 | if (IN6_IS_ADDR_LINKLOCAL(&p->u.prefix6)) |
| 65 | return 0; |
| 66 | } |
| 67 | #endif /* HAVE_IPV6 */ |
| 68 | return 1; |
| 69 | } |
| 70 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 71 | int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | is_default (struct prefix *p) |
| 73 | { |
| 74 | if (p->family == AF_INET) |
| 75 | if (p->u.prefix4.s_addr == 0 && p->prefixlen == 0) |
| 76 | return 1; |
| 77 | #ifdef HAVE_IPV6 |
| 78 | #if 0 /* IPv6 default separation is now pending until protocol daemon |
| 79 | can handle that. */ |
| 80 | if (p->family == AF_INET6) |
| 81 | if (IN6_IS_ADDR_UNSPECIFIED (&p->u.prefix6) && p->prefixlen == 0) |
| 82 | return 1; |
| 83 | #endif /* 0 */ |
| 84 | #endif /* HAVE_IPV6 */ |
| 85 | return 0; |
| 86 | } |
| 87 | |
ajs | 27da398 | 2005-02-24 16:06:33 +0000 | [diff] [blame] | 88 | static void |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 89 | zebra_redistribute_default (struct zserv *client, vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 90 | { |
| 91 | struct prefix_ipv4 p; |
| 92 | struct route_table *table; |
| 93 | struct route_node *rn; |
| 94 | struct rib *newrib; |
| 95 | #ifdef HAVE_IPV6 |
| 96 | struct prefix_ipv6 p6; |
| 97 | #endif /* HAVE_IPV6 */ |
| 98 | |
| 99 | |
| 100 | /* Lookup default route. */ |
| 101 | memset (&p, 0, sizeof (struct prefix_ipv4)); |
| 102 | p.family = AF_INET; |
| 103 | |
| 104 | /* Lookup table. */ |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 105 | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 106 | if (table) |
| 107 | { |
| 108 | rn = route_node_lookup (table, (struct prefix *)&p); |
| 109 | if (rn) |
| 110 | { |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 111 | RNODE_FOREACH_RIB (rn, newrib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 112 | if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED) |
| 113 | && newrib->distance != DISTANCE_INFINITY) |
paul | b9df2d2 | 2004-05-09 09:09:59 +0000 | [diff] [blame] | 114 | zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, &rn->p, newrib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 115 | route_unlock_node (rn); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | #ifdef HAVE_IPV6 |
| 120 | /* Lookup default route. */ |
| 121 | memset (&p6, 0, sizeof (struct prefix_ipv6)); |
| 122 | p6.family = AF_INET6; |
| 123 | |
| 124 | /* Lookup table. */ |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 125 | table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 126 | if (table) |
| 127 | { |
| 128 | rn = route_node_lookup (table, (struct prefix *)&p6); |
| 129 | if (rn) |
| 130 | { |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 131 | RNODE_FOREACH_RIB (rn, newrib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED) |
| 133 | && newrib->distance != DISTANCE_INFINITY) |
paul | b9df2d2 | 2004-05-09 09:09:59 +0000 | [diff] [blame] | 134 | zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, &rn->p, newrib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 135 | route_unlock_node (rn); |
| 136 | } |
| 137 | } |
| 138 | #endif /* HAVE_IPV6 */ |
| 139 | } |
| 140 | |
| 141 | /* Redistribute routes. */ |
ajs | 27da398 | 2005-02-24 16:06:33 +0000 | [diff] [blame] | 142 | static void |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 143 | zebra_redistribute (struct zserv *client, int type, vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 144 | { |
| 145 | struct rib *newrib; |
| 146 | struct route_table *table; |
| 147 | struct route_node *rn; |
| 148 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 149 | table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 150 | if (table) |
| 151 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 152 | RNODE_FOREACH_RIB (rn, newrib) |
Lou Berger | 40278bd | 2016-01-12 13:41:45 -0500 | [diff] [blame] | 153 | { |
| 154 | if (IS_ZEBRA_DEBUG_EVENT) |
| 155 | zlog_debug("%s: checking: selected=%d, type=%d, distance=%d, zebra_check_addr=%d", |
| 156 | __func__, CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED), |
| 157 | newrib->type, newrib->distance, zebra_check_addr (&rn->p)); |
| 158 | if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED) |
| 159 | && newrib->type == type |
| 160 | && newrib->distance != DISTANCE_INFINITY |
| 161 | && zebra_check_addr (&rn->p)) |
| 162 | zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, &rn->p, newrib); |
| 163 | } |
| 164 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 165 | #ifdef HAVE_IPV6 |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 166 | table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 167 | if (table) |
| 168 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 169 | RNODE_FOREACH_RIB (rn, newrib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 170 | if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED) |
| 171 | && newrib->type == type |
| 172 | && newrib->distance != DISTANCE_INFINITY |
| 173 | && zebra_check_addr (&rn->p)) |
paul | b9df2d2 | 2004-05-09 09:09:59 +0000 | [diff] [blame] | 174 | zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, &rn->p, newrib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 175 | #endif /* HAVE_IPV6 */ |
| 176 | } |
| 177 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 178 | void |
| 179 | redistribute_add (struct prefix *p, struct rib *rib) |
| 180 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 181 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 182 | struct zserv *client; |
| 183 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 184 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) |
| 185 | { |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 186 | if ((is_default (p) && |
| 187 | vrf_bitmap_check (client->redist_default, rib->vrf_id)) |
| 188 | || vrf_bitmap_check (client->redist[rib->type], rib->vrf_id)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 189 | { |
| 190 | if (p->family == AF_INET) |
| 191 | zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 192 | #ifdef HAVE_IPV6 |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 193 | if (p->family == AF_INET6) |
| 194 | zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 195 | #endif /* HAVE_IPV6 */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 196 | } |
| 197 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | void |
| 201 | redistribute_delete (struct prefix *p, struct rib *rib) |
| 202 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 203 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 204 | struct zserv *client; |
| 205 | |
| 206 | /* Add DISTANCE_INFINITY check. */ |
| 207 | if (rib->distance == DISTANCE_INFINITY) |
| 208 | return; |
| 209 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 210 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) |
| 211 | { |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 212 | if ((is_default (p) && |
| 213 | vrf_bitmap_check (client->redist_default, rib->vrf_id)) |
| 214 | || vrf_bitmap_check (client->redist[rib->type], rib->vrf_id)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 215 | { |
| 216 | if (p->family == AF_INET) |
| 217 | zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 218 | #ifdef HAVE_IPV6 |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 219 | if (p->family == AF_INET6) |
| 220 | zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib); |
| 221 | #endif /* HAVE_IPV6 */ |
| 222 | } |
| 223 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | void |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 227 | zebra_redistribute_add (int command, struct zserv *client, int length, |
| 228 | vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 229 | { |
| 230 | int type; |
| 231 | |
| 232 | type = stream_getc (client->ibuf); |
| 233 | |
David Lamparter | ebf0863 | 2009-08-27 00:27:40 +0200 | [diff] [blame] | 234 | if (type == 0 || type >= ZEBRA_ROUTE_MAX) |
| 235 | return; |
| 236 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 237 | if (! vrf_bitmap_check (client->redist[type], vrf_id)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | { |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 239 | vrf_bitmap_set (client->redist[type], vrf_id); |
| 240 | zebra_redistribute (client, type, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 241 | } |
David Lamparter | ebf0863 | 2009-08-27 00:27:40 +0200 | [diff] [blame] | 242 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 243 | |
| 244 | void |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 245 | zebra_redistribute_delete (int command, struct zserv *client, int length, |
| 246 | vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 247 | { |
| 248 | int type; |
| 249 | |
| 250 | type = stream_getc (client->ibuf); |
| 251 | |
David Lamparter | ebf0863 | 2009-08-27 00:27:40 +0200 | [diff] [blame] | 252 | if (type == 0 || type >= ZEBRA_ROUTE_MAX) |
| 253 | return; |
| 254 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 255 | vrf_bitmap_unset (client->redist[type], vrf_id); |
David Lamparter | ebf0863 | 2009-08-27 00:27:40 +0200 | [diff] [blame] | 256 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 257 | |
| 258 | void |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 259 | zebra_redistribute_default_add (int command, struct zserv *client, int length, |
| 260 | vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 261 | { |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 262 | vrf_bitmap_set (client->redist_default, vrf_id); |
| 263 | zebra_redistribute_default (client, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | void |
| 267 | zebra_redistribute_default_delete (int command, struct zserv *client, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 268 | int length, vrf_id_t vrf_id) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 269 | { |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 270 | vrf_bitmap_unset (client->redist_default, vrf_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | /* Interface up information. */ |
| 274 | void |
| 275 | zebra_interface_up_update (struct interface *ifp) |
| 276 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 277 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 278 | struct zserv *client; |
| 279 | |
| 280 | if (IS_ZEBRA_DEBUG_EVENT) |
ajs | b617800 | 2004-12-07 21:12:56 +0000 | [diff] [blame] | 281 | zlog_debug ("MESSAGE: ZEBRA_INTERFACE_UP %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 282 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 283 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) |
Olivier Dugeon | 15773a8 | 2016-04-19 18:29:55 +0200 | [diff] [blame] | 284 | if (client->ifinfo) |
| 285 | { |
| 286 | zsend_interface_update (ZEBRA_INTERFACE_UP, client, ifp); |
| 287 | zsend_interface_link_params (client, ifp); |
| 288 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | /* Interface down information. */ |
| 292 | void |
| 293 | zebra_interface_down_update (struct interface *ifp) |
| 294 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 295 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 296 | struct zserv *client; |
| 297 | |
| 298 | if (IS_ZEBRA_DEBUG_EVENT) |
ajs | b617800 | 2004-12-07 21:12:56 +0000 | [diff] [blame] | 299 | zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DOWN %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 300 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 301 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) |
| 302 | zsend_interface_update (ZEBRA_INTERFACE_DOWN, client, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | /* Interface information update. */ |
| 306 | void |
| 307 | zebra_interface_add_update (struct interface *ifp) |
| 308 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 309 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 310 | struct zserv *client; |
| 311 | |
| 312 | if (IS_ZEBRA_DEBUG_EVENT) |
ajs | b617800 | 2004-12-07 21:12:56 +0000 | [diff] [blame] | 313 | zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADD %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 314 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 315 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) |
| 316 | if (client->ifinfo) |
Olivier Dugeon | 15773a8 | 2016-04-19 18:29:55 +0200 | [diff] [blame] | 317 | { |
| 318 | zsend_interface_add (client, ifp); |
| 319 | zsend_interface_link_params (client, ifp); |
| 320 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | void |
| 324 | zebra_interface_delete_update (struct interface *ifp) |
| 325 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 326 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 327 | struct zserv *client; |
| 328 | |
| 329 | if (IS_ZEBRA_DEBUG_EVENT) |
ajs | b617800 | 2004-12-07 21:12:56 +0000 | [diff] [blame] | 330 | zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DELETE %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 331 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 332 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) |
| 333 | if (client->ifinfo) |
| 334 | zsend_interface_delete (client, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | /* Interface address addition. */ |
| 338 | void |
| 339 | zebra_interface_address_add_update (struct interface *ifp, |
| 340 | struct connected *ifc) |
| 341 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 342 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 343 | struct zserv *client; |
| 344 | struct prefix *p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 345 | |
| 346 | if (IS_ZEBRA_DEBUG_EVENT) |
| 347 | { |
Timo Teräs | be6335d | 2015-05-23 11:08:41 +0300 | [diff] [blame] | 348 | char buf[PREFIX_STRLEN]; |
Stephen Hemminger | 81cce01 | 2009-04-28 14:28:00 -0700 | [diff] [blame] | 349 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 350 | p = ifc->address; |
Timo Teräs | be6335d | 2015-05-23 11:08:41 +0300 | [diff] [blame] | 351 | zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %s on %s", |
| 352 | prefix2str (p, buf, sizeof(buf)), |
| 353 | ifc->ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 354 | } |
| 355 | |
Christian Franke | c7df92d | 2013-01-24 14:04:47 +0000 | [diff] [blame] | 356 | if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL)) |
| 357 | zlog_warn("WARNING: advertising address to clients that is not yet usable."); |
| 358 | |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 359 | router_id_add_address(ifc); |
| 360 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 361 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) |
| 362 | if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) |
| 363 | zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client, ifp, ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | /* Interface address deletion. */ |
| 367 | void |
| 368 | zebra_interface_address_delete_update (struct interface *ifp, |
| 369 | struct connected *ifc) |
| 370 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 371 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 372 | struct zserv *client; |
| 373 | struct prefix *p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 374 | |
| 375 | if (IS_ZEBRA_DEBUG_EVENT) |
| 376 | { |
Timo Teräs | be6335d | 2015-05-23 11:08:41 +0300 | [diff] [blame] | 377 | char buf[PREFIX_STRLEN]; |
Stephen Hemminger | 81cce01 | 2009-04-28 14:28:00 -0700 | [diff] [blame] | 378 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 379 | p = ifc->address; |
Timo Teräs | be6335d | 2015-05-23 11:08:41 +0300 | [diff] [blame] | 380 | zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %s on %s", |
| 381 | prefix2str (p, buf, sizeof(buf)), |
| 382 | ifc->ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 383 | } |
| 384 | |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 385 | router_id_del_address(ifc); |
| 386 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 387 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) |
| 388 | if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) |
| 389 | zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_DELETE, client, ifp, ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 390 | } |
Olivier Dugeon | 15773a8 | 2016-04-19 18:29:55 +0200 | [diff] [blame] | 391 | |
| 392 | /* Interface parameters update */ |
| 393 | void |
| 394 | zebra_interface_parameters_update (struct interface *ifp) |
| 395 | { |
| 396 | struct listnode *node, *nnode; |
| 397 | struct zserv *client; |
| 398 | |
| 399 | if (IS_ZEBRA_DEBUG_EVENT) |
| 400 | zlog_debug ("MESSAGE: ZEBRA_INTERFACE_LINK_PARAMS %s", ifp->name); |
| 401 | |
| 402 | for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) |
| 403 | if (client->ifinfo) |
| 404 | zsend_interface_link_params (client, ifp); |
| 405 | } |