version 1.1.1.2, 2012/10/09 09:22:28
|
version 1.1.1.3, 2016/11/02 10:09:11
|
Line 49 struct in_addr router_id_zebra;
|
Line 49 struct in_addr router_id_zebra;
|
/* Router-id update message from zebra. */ |
/* Router-id update message from zebra. */ |
static int |
static int |
ospf6_router_id_update_zebra (int command, struct zclient *zclient, |
ospf6_router_id_update_zebra (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct prefix router_id; |
struct prefix router_id; |
struct ospf6 *o = ospf6; |
struct ospf6 *o = ospf6; |
Line 70 ospf6_router_id_update_zebra (int command, struct zcli
|
Line 70 ospf6_router_id_update_zebra (int command, struct zcli
|
void |
void |
ospf6_zebra_redistribute (int type) |
ospf6_zebra_redistribute (int type) |
{ |
{ |
if (zclient->redist[type]) | if (vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT)) |
return; |
return; |
zclient->redist[type] = 1; | vrf_bitmap_set (zclient->redist[type], VRF_DEFAULT); |
if (zclient->sock > 0) |
if (zclient->sock > 0) |
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type); | zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type, |
| VRF_DEFAULT); |
} |
} |
|
|
void |
void |
ospf6_zebra_no_redistribute (int type) |
ospf6_zebra_no_redistribute (int type) |
{ |
{ |
if (! zclient->redist[type]) | if (! vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT)) |
return; |
return; |
zclient->redist[type] = 0; | vrf_bitmap_unset (zclient->redist[type], VRF_DEFAULT); |
if (zclient->sock > 0) |
if (zclient->sock > 0) |
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type); | zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, |
| VRF_DEFAULT); |
} |
} |
|
|
/* Inteface addition message from zebra. */ |
/* Inteface addition message from zebra. */ |
static int |
static int |
ospf6_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length) | ospf6_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length, |
| vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
|
|
ifp = zebra_interface_add_read (zclient->ibuf); | ifp = zebra_interface_add_read (zclient->ibuf, vrf_id); |
if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
zlog_debug ("Zebra Interface add: %s index %d mtu %d", |
zlog_debug ("Zebra Interface add: %s index %d mtu %d", |
ifp->name, ifp->ifindex, ifp->mtu6); |
ifp->name, ifp->ifindex, ifp->mtu6); |
Line 102 ospf6_zebra_if_add (int command, struct zclient *zclie
|
Line 105 ospf6_zebra_if_add (int command, struct zclient *zclie
|
} |
} |
|
|
static int |
static int |
ospf6_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length) | ospf6_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length, |
| vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
|
|
if (!(ifp = zebra_interface_state_read(zclient->ibuf))) | if (!(ifp = zebra_interface_state_read (zclient->ibuf, vrf_id))) |
return 0; |
return 0; |
|
|
if (if_is_up (ifp)) |
if (if_is_up (ifp)) |
Line 117 ospf6_zebra_if_del (int command, struct zclient *zclie
|
Line 121 ospf6_zebra_if_del (int command, struct zclient *zclie
|
ifp->name, ifp->ifindex, ifp->mtu6); |
ifp->name, ifp->ifindex, ifp->mtu6); |
|
|
#if 0 |
#if 0 |
/* Why is this commented out? */ | /* XXX: ospf6_interface_if_del is not the right way to handle this, |
| * because among other thinkable issues, it will also clear all |
| * settings as they are contained in the struct ospf6_interface. */ |
ospf6_interface_if_del (ifp); |
ospf6_interface_if_del (ifp); |
#endif /*0*/ |
#endif /*0*/ |
|
|
Line 127 ospf6_zebra_if_del (int command, struct zclient *zclie
|
Line 133 ospf6_zebra_if_del (int command, struct zclient *zclie
|
|
|
static int |
static int |
ospf6_zebra_if_state_update (int command, struct zclient *zclient, |
ospf6_zebra_if_state_update (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
|
|
ifp = zebra_interface_state_read (zclient->ibuf); | ifp = zebra_interface_state_read (zclient->ibuf, vrf_id); |
if (ifp == NULL) |
if (ifp == NULL) |
return 0; |
return 0; |
|
|
if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
zlog_debug ("Zebra Interface state change: " |
zlog_debug ("Zebra Interface state change: " |
"%s index %d flags %llx metric %d mtu %d", | "%s index %d flags %llx metric %d mtu %d bandwidth %d", |
ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, |
ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, |
ifp->metric, ifp->mtu6); | ifp->metric, ifp->mtu6, ifp->bandwidth); |
|
|
ospf6_interface_state_update (ifp); |
ospf6_interface_state_update (ifp); |
return 0; |
return 0; |
Line 147 ospf6_zebra_if_state_update (int command, struct zclie
|
Line 153 ospf6_zebra_if_state_update (int command, struct zclie
|
|
|
static int |
static int |
ospf6_zebra_if_address_update_add (int command, struct zclient *zclient, |
ospf6_zebra_if_address_update_add (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct connected *c; |
struct connected *c; |
char buf[128]; |
char buf[128]; |
|
|
c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, zclient->ibuf); | c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, zclient->ibuf, |
| vrf_id); |
if (c == NULL) |
if (c == NULL) |
return 0; |
return 0; |
|
|
Line 163 ospf6_zebra_if_address_update_add (int command, struct
|
Line 170 ospf6_zebra_if_address_update_add (int command, struct
|
buf, sizeof (buf)), c->address->prefixlen); |
buf, sizeof (buf)), c->address->prefixlen); |
|
|
if (c->address->family == AF_INET6) |
if (c->address->family == AF_INET6) |
ospf6_interface_connected_route_update (c->ifp); | { |
| ospf6_interface_state_update (c->ifp); |
| ospf6_interface_connected_route_update (c->ifp); |
| } |
return 0; |
return 0; |
} |
} |
|
|
static int |
static int |
ospf6_zebra_if_address_update_delete (int command, struct zclient *zclient, |
ospf6_zebra_if_address_update_delete (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct connected *c; |
struct connected *c; |
char buf[128]; |
char buf[128]; |
|
|
c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, zclient->ibuf); | c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, zclient->ibuf, |
| vrf_id); |
if (c == NULL) |
if (c == NULL) |
return 0; |
return 0; |
|
|
Line 186 ospf6_zebra_if_address_update_delete (int command, str
|
Line 196 ospf6_zebra_if_address_update_delete (int command, str
|
buf, sizeof (buf)), c->address->prefixlen); |
buf, sizeof (buf)), c->address->prefixlen); |
|
|
if (c->address->family == AF_INET6) |
if (c->address->family == AF_INET6) |
ospf6_interface_connected_route_update (c->ifp); | { |
| ospf6_interface_connected_route_update (c->ifp); |
| ospf6_interface_state_update (c->ifp); |
| } |
|
|
return 0; |
return 0; |
} |
} |
|
|
static int |
static int |
ospf6_zebra_read_ipv6 (int command, struct zclient *zclient, |
ospf6_zebra_read_ipv6 (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct stream *s; |
struct stream *s; |
struct zapi_ipv6 api; |
struct zapi_ipv6 api; |
unsigned long ifindex; |
unsigned long ifindex; |
struct prefix_ipv6 p; |
struct prefix_ipv6 p; |
struct in6_addr *nexthop; |
struct in6_addr *nexthop; |
|
unsigned char plength = 0; |
|
|
s = zclient->ibuf; |
s = zclient->ibuf; |
ifindex = 0; |
ifindex = 0; |
Line 214 ospf6_zebra_read_ipv6 (int command, struct zclient *zc
|
Line 228 ospf6_zebra_read_ipv6 (int command, struct zclient *zc
|
/* IPv6 prefix. */ |
/* IPv6 prefix. */ |
memset (&p, 0, sizeof (struct prefix_ipv6)); |
memset (&p, 0, sizeof (struct prefix_ipv6)); |
p.family = AF_INET6; |
p.family = AF_INET6; |
p.prefixlen = stream_getc (s); | plength = stream_getc (s); |
| p.prefixlen = MIN(IPV6_MAX_PREFIXLEN, plength); |
stream_get (&p.prefix, s, PSIZE (p.prefixlen)); |
stream_get (&p.prefix, s, PSIZE (p.prefixlen)); |
|
|
/* Nexthop, ifindex, distance, metric. */ |
/* Nexthop, ifindex, distance, metric. */ |
Line 267 ospf6_zebra_read_ipv6 (int command, struct zclient *zc
|
Line 282 ospf6_zebra_read_ipv6 (int command, struct zclient *zc
|
|
|
|
|
|
|
| |
DEFUN (show_zebra, |
DEFUN (show_zebra, |
show_zebra_cmd, |
show_zebra_cmd, |
"show zebra", |
"show zebra", |
Line 284 DEFUN (show_zebra,
|
Line 299 DEFUN (show_zebra,
|
vty_out (vty, "Zebra Infomation%s", VNL); |
vty_out (vty, "Zebra Infomation%s", VNL); |
vty_out (vty, " enable: %d fail: %d%s", |
vty_out (vty, " enable: %d fail: %d%s", |
zclient->enable, zclient->fail, VNL); |
zclient->enable, zclient->fail, VNL); |
vty_out (vty, " redistribute default: %d%s", zclient->redist_default, | vty_out (vty, " redistribute default: %d%s", |
| vrf_bitmap_check (zclient->default_information, VRF_DEFAULT), |
VNL); |
VNL); |
vty_out (vty, " redistribute:"); |
vty_out (vty, " redistribute:"); |
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
{ |
{ |
if (zclient->redist[i]) | if (vrf_bitmap_check (zclient->redist[i], VRF_DEFAULT)) |
vty_out (vty, " %s", zebra_route_string(i)); |
vty_out (vty, " %s", zebra_route_string(i)); |
} |
} |
vty_out (vty, "%s", VNL); |
vty_out (vty, "%s", VNL); |
Line 329 config_write_ospf6_zebra (struct vty *vty)
|
Line 345 config_write_ospf6_zebra (struct vty *vty)
|
vty_out (vty, "no router zebra%s", VNL); |
vty_out (vty, "no router zebra%s", VNL); |
vty_out (vty, "!%s", VNL); |
vty_out (vty, "!%s", VNL); |
} |
} |
else if (! zclient->redist[ZEBRA_ROUTE_OSPF6]) | else if (! vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF6], VRF_DEFAULT)) |
{ |
{ |
vty_out (vty, "router zebra%s", VNL); |
vty_out (vty, "router zebra%s", VNL); |
vty_out (vty, " no redistribute ospf6%s", VNL); |
vty_out (vty, " no redistribute ospf6%s", VNL); |
Line 354 ospf6_zebra_route_update (int type, struct ospf6_route
|
Line 370 ospf6_zebra_route_update (int type, struct ospf6_route
|
char buf[64]; |
char buf[64]; |
int nhcount; |
int nhcount; |
struct in6_addr **nexthops; |
struct in6_addr **nexthops; |
unsigned int *ifindexes; | ifindex_t *ifindexes; |
int i, ret = 0; |
int i, ret = 0; |
struct prefix_ipv6 *dest; |
struct prefix_ipv6 *dest; |
|
|
Line 436 ospf6_zebra_route_update (int type, struct ospf6_route
|
Line 452 ospf6_zebra_route_update (int type, struct ospf6_route
|
{ |
{ |
if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
{ |
{ |
char ifname[IFNAMSIZ]; | const char *ifname; |
inet_ntop (AF_INET6, &request->nexthop[i].address, |
inet_ntop (AF_INET6, &request->nexthop[i].address, |
buf, sizeof (buf)); |
buf, sizeof (buf)); |
if (!if_indextoname(request->nexthop[i].ifindex, ifname)) | ifname = ifindex2ifname (request->nexthop[i].ifindex); |
strlcpy(ifname, "unknown", sizeof(ifname)); | |
zlog_debug (" nexthop: %s%%%.*s(%d)", buf, IFNAMSIZ, ifname, |
zlog_debug (" nexthop: %s%%%.*s(%d)", buf, IFNAMSIZ, ifname, |
request->nexthop[i].ifindex); |
request->nexthop[i].ifindex); |
} |
} |
Line 448 ospf6_zebra_route_update (int type, struct ospf6_route
|
Line 463 ospf6_zebra_route_update (int type, struct ospf6_route
|
ifindexes[i] = request->nexthop[i].ifindex; |
ifindexes[i] = request->nexthop[i].ifindex; |
} |
} |
|
|
|
api.vrf_id = VRF_DEFAULT; |
api.type = ZEBRA_ROUTE_OSPF6; |
api.type = ZEBRA_ROUTE_OSPF6; |
api.flags = 0; |
api.flags = 0; |
api.message = 0; |
api.message = 0; |
Line 481 ospf6_zebra_route_update (int type, struct ospf6_route
|
Line 497 ospf6_zebra_route_update (int type, struct ospf6_route
|
void |
void |
ospf6_zebra_route_update_add (struct ospf6_route *request) |
ospf6_zebra_route_update_add (struct ospf6_route *request) |
{ |
{ |
if (! zclient->redist[ZEBRA_ROUTE_OSPF6]) | if (! vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF6], VRF_DEFAULT)) |
{ |
{ |
ospf6->route_table->hook_add = NULL; |
ospf6->route_table->hook_add = NULL; |
ospf6->route_table->hook_remove = NULL; |
ospf6->route_table->hook_remove = NULL; |
Line 493 ospf6_zebra_route_update_add (struct ospf6_route *requ
|
Line 509 ospf6_zebra_route_update_add (struct ospf6_route *requ
|
void |
void |
ospf6_zebra_route_update_remove (struct ospf6_route *request) |
ospf6_zebra_route_update_remove (struct ospf6_route *request) |
{ |
{ |
if (! zclient->redist[ZEBRA_ROUTE_OSPF6]) | if (! vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF6], VRF_DEFAULT)) |
{ |
{ |
ospf6->route_table->hook_add = NULL; |
ospf6->route_table->hook_add = NULL; |
ospf6->route_table->hook_remove = NULL; |
ospf6->route_table->hook_remove = NULL; |
Line 510 DEFUN (redistribute_ospf6,
|
Line 526 DEFUN (redistribute_ospf6,
|
{ |
{ |
struct ospf6_route *route; |
struct ospf6_route *route; |
|
|
if (zclient->redist[ZEBRA_ROUTE_OSPF6]) | if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF6], VRF_DEFAULT)) |
return CMD_SUCCESS; |
return CMD_SUCCESS; |
|
|
zclient->redist[ZEBRA_ROUTE_OSPF6] = 1; | vrf_bitmap_set (zclient->redist[ZEBRA_ROUTE_OSPF6], VRF_DEFAULT); |
|
|
if (ospf6 == NULL) |
if (ospf6 == NULL) |
return CMD_SUCCESS; |
return CMD_SUCCESS; |
Line 538 DEFUN (no_redistribute_ospf6,
|
Line 554 DEFUN (no_redistribute_ospf6,
|
{ |
{ |
struct ospf6_route *route; |
struct ospf6_route *route; |
|
|
if (! zclient->redist[ZEBRA_ROUTE_OSPF6]) | if (! vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF6], VRF_DEFAULT)) |
return CMD_SUCCESS; |
return CMD_SUCCESS; |
|
|
zclient->redist[ZEBRA_ROUTE_OSPF6] = 0; | vrf_bitmap_unset (zclient->redist[ZEBRA_ROUTE_OSPF6], VRF_DEFAULT); |
|
|
if (ospf6 == NULL) |
if (ospf6 == NULL) |
return CMD_SUCCESS; |
return CMD_SUCCESS; |
Line 557 DEFUN (no_redistribute_ospf6,
|
Line 573 DEFUN (no_redistribute_ospf6,
|
return CMD_SUCCESS; |
return CMD_SUCCESS; |
} |
} |
|
|
|
static void |
|
ospf6_zebra_connected (struct zclient *zclient) |
|
{ |
|
zclient_send_requests (zclient, VRF_DEFAULT); |
|
} |
|
|
void |
void |
ospf6_zebra_init (void) | ospf6_zebra_init (struct thread_master *master) |
{ |
{ |
/* Allocate zebra structure. */ |
/* Allocate zebra structure. */ |
zclient = zclient_new (); | zclient = zclient_new (master); |
zclient_init (zclient, ZEBRA_ROUTE_OSPF6); |
zclient_init (zclient, ZEBRA_ROUTE_OSPF6); |
|
zclient->zebra_connected = ospf6_zebra_connected; |
zclient->router_id_update = ospf6_router_id_update_zebra; |
zclient->router_id_update = ospf6_router_id_update_zebra; |
zclient->interface_add = ospf6_zebra_if_add; |
zclient->interface_add = ospf6_zebra_if_add; |
zclient->interface_delete = ospf6_zebra_if_del; |
zclient->interface_delete = ospf6_zebra_if_del; |
Line 595 ospf6_zebra_init (void)
|
Line 618 ospf6_zebra_init (void)
|
} |
} |
|
|
/* Debug */ |
/* Debug */ |
| |
DEFUN (debug_ospf6_zebra_sendrecv, |
DEFUN (debug_ospf6_zebra_sendrecv, |
debug_ospf6_zebra_sendrecv_cmd, |
debug_ospf6_zebra_sendrecv_cmd, |
"debug ospf6 zebra (send|recv)", |
"debug ospf6 zebra (send|recv)", |