version 1.1.1.3, 2013/07/21 23:54:40
|
version 1.1.1.4, 2016/11/02 10:09:12
|
Line 59 struct in_addr router_id_zebra;
|
Line 59 struct in_addr router_id_zebra;
|
/* Router-id update message from zebra. */ |
/* Router-id update message from zebra. */ |
static int |
static int |
ospf_router_id_update_zebra (int command, struct zclient *zclient, |
ospf_router_id_update_zebra (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct ospf *ospf; |
struct ospf *ospf; |
struct prefix router_id; |
struct prefix router_id; |
Line 84 ospf_router_id_update_zebra (int command, struct zclie
|
Line 84 ospf_router_id_update_zebra (int command, struct zclie
|
|
|
/* Inteface addition message from zebra. */ |
/* Inteface addition message from zebra. */ |
static int |
static int |
ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length) | ospf_interface_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_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
zlog_debug ("Zebra: interface add %s index %d flags %llx metric %d mtu %d", |
zlog_debug ("Zebra: interface add %s index %d flags %llx metric %d mtu %d", |
Line 114 ospf_interface_add (int command, struct zclient *zclie
|
Line 115 ospf_interface_add (int command, struct zclient *zclie
|
|
|
static int |
static int |
ospf_interface_delete (int command, struct zclient *zclient, |
ospf_interface_delete (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
struct stream *s; |
struct stream *s; |
Line 122 ospf_interface_delete (int command, struct zclient *zc
|
Line 123 ospf_interface_delete (int command, struct zclient *zc
|
|
|
s = zclient->ibuf; |
s = zclient->ibuf; |
/* zebra_interface_state_read() updates interface structure in iflist */ |
/* zebra_interface_state_read() updates interface structure in iflist */ |
ifp = zebra_interface_state_read (s); | ifp = zebra_interface_state_read (s, vrf_id); |
|
|
if (ifp == NULL) |
if (ifp == NULL) |
return 0; |
return 0; |
Line 149 ospf_interface_delete (int command, struct zclient *zc
|
Line 150 ospf_interface_delete (int command, struct zclient *zc
|
} |
} |
|
|
static struct interface * |
static struct interface * |
zebra_interface_if_lookup (struct stream *s) | zebra_interface_if_lookup (struct stream *s, vrf_id_t vrf_id) |
{ |
{ |
char ifname_tmp[INTERFACE_NAMSIZ]; |
char ifname_tmp[INTERFACE_NAMSIZ]; |
|
|
Line 163 zebra_interface_if_lookup (struct stream *s)
|
Line 164 zebra_interface_if_lookup (struct stream *s)
|
|
|
static int |
static int |
ospf_interface_state_up (int command, struct zclient *zclient, |
ospf_interface_state_up (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
struct ospf_interface *oi; |
struct ospf_interface *oi; |
struct route_node *rn; |
struct route_node *rn; |
|
|
ifp = zebra_interface_if_lookup (zclient->ibuf); | ifp = zebra_interface_if_lookup (zclient->ibuf, vrf_id); |
|
|
if (ifp == NULL) |
if (ifp == NULL) |
return 0; |
return 0; |
Line 225 ospf_interface_state_up (int command, struct zclient *
|
Line 226 ospf_interface_state_up (int command, struct zclient *
|
|
|
static int |
static int |
ospf_interface_state_down (int command, struct zclient *zclient, |
ospf_interface_state_down (int command, struct zclient *zclient, |
zebra_size_t length) | zebra_size_t length, vrf_id_t vrf_id) |
{ |
{ |
struct interface *ifp; |
struct interface *ifp; |
struct ospf_interface *oi; |
struct ospf_interface *oi; |
struct route_node *node; |
struct route_node *node; |
|
|
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; |
Line 251 ospf_interface_state_down (int command, struct zclient
|
Line 252 ospf_interface_state_down (int command, struct zclient
|
|
|
static int |
static int |
ospf_interface_address_add (int command, struct zclient *zclient, |
ospf_interface_address_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; |
|
|
c = zebra_interface_address_read (command, zclient->ibuf); | c = zebra_interface_address_read (command, zclient->ibuf, vrf_id); |
|
|
if (c == NULL) |
if (c == NULL) |
return 0; |
return 0; |
Line 278 ospf_interface_address_add (int command, struct zclien
|
Line 279 ospf_interface_address_add (int command, struct zclien
|
|
|
static int |
static int |
ospf_interface_address_delete (int command, struct zclient *zclient, |
ospf_interface_address_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; |
struct interface *ifp; |
struct interface *ifp; |
Line 286 ospf_interface_address_delete (int command, struct zcl
|
Line 287 ospf_interface_address_delete (int command, struct zcl
|
struct route_node *rn; |
struct route_node *rn; |
struct prefix p; |
struct prefix p; |
|
|
c = zebra_interface_address_read (command, zclient->ibuf); | c = zebra_interface_address_read (command, zclient->ibuf, vrf_id); |
|
|
if (c == NULL) |
if (c == NULL) |
return 0; |
return 0; |
Line 311 ospf_interface_address_delete (int command, struct zcl
|
Line 312 ospf_interface_address_delete (int command, struct zcl
|
|
|
assert (rn->info); |
assert (rn->info); |
oi = rn->info; |
oi = rn->info; |
|
route_unlock_node (rn); |
|
|
/* Call interface hook functions to clean up */ |
/* Call interface hook functions to clean up */ |
ospf_if_free (oi); |
ospf_if_free (oi); |
Line 335 ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_rou
|
Line 337 ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_rou
|
struct ospf_path *path; |
struct ospf_path *path; |
struct listnode *node; |
struct listnode *node; |
|
|
if (zclient->redist[ZEBRA_ROUTE_OSPF]) | if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT)) |
{ |
{ |
message = 0; |
message = 0; |
flags = 0; |
flags = 0; |
Line 354 ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_rou
|
Line 356 ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_rou
|
stream_reset (s); |
stream_reset (s); |
|
|
/* Put command, type, flags, message. */ |
/* Put command, type, flags, message. */ |
zclient_create_header (s, ZEBRA_IPV4_ROUTE_ADD); | zclient_create_header (s, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT); |
stream_putc (s, ZEBRA_ROUTE_OSPF); |
stream_putc (s, ZEBRA_ROUTE_OSPF); |
stream_putc (s, flags); |
stream_putc (s, flags); |
stream_putc (s, message); |
stream_putc (s, message); |
Line 433 ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_
|
Line 435 ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_
|
struct ospf_path *path; |
struct ospf_path *path; |
struct listnode *node; |
struct listnode *node; |
|
|
if (zclient->redist[ZEBRA_ROUTE_OSPF]) | if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT)) |
{ |
{ |
message = 0; |
message = 0; |
flags = 0; |
flags = 0; |
Line 444 ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_
|
Line 446 ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_
|
stream_reset (s); |
stream_reset (s); |
|
|
/* Put command, type, flags, message. */ |
/* Put command, type, flags, message. */ |
zclient_create_header (s, ZEBRA_IPV4_ROUTE_DELETE); | zclient_create_header (s, ZEBRA_IPV4_ROUTE_DELETE, VRF_DEFAULT); |
stream_putc (s, ZEBRA_ROUTE_OSPF); |
stream_putc (s, ZEBRA_ROUTE_OSPF); |
stream_putc (s, flags); |
stream_putc (s, flags); |
stream_putc (s, message); |
stream_putc (s, message); |
Line 482 ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_
|
Line 484 ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_
|
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
{ |
{ |
char buf[2][INET_ADDRSTRLEN]; |
char buf[2][INET_ADDRSTRLEN]; |
zlog_debug("Zebra: Route add %s/%d nexthop %s", | zlog_debug("Zebra: Route delete %s/%d nexthop %s", |
inet_ntop(AF_INET, &p->prefix, |
inet_ntop(AF_INET, &p->prefix, |
buf[0], sizeof(buf[0])), |
buf[0], sizeof(buf[0])), |
p->prefixlen, |
p->prefixlen, |
Line 514 ospf_zebra_add_discard (struct prefix_ipv4 *p)
|
Line 516 ospf_zebra_add_discard (struct prefix_ipv4 *p)
|
{ |
{ |
struct zapi_ipv4 api; |
struct zapi_ipv4 api; |
|
|
if (zclient->redist[ZEBRA_ROUTE_OSPF]) | if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT)) |
{ |
{ |
|
api.vrf_id = VRF_DEFAULT; |
api.type = ZEBRA_ROUTE_OSPF; |
api.type = ZEBRA_ROUTE_OSPF; |
api.flags = ZEBRA_FLAG_BLACKHOLE; |
api.flags = ZEBRA_FLAG_BLACKHOLE; |
api.message = 0; |
api.message = 0; |
Line 537 ospf_zebra_delete_discard (struct prefix_ipv4 *p)
|
Line 540 ospf_zebra_delete_discard (struct prefix_ipv4 *p)
|
{ |
{ |
struct zapi_ipv4 api; |
struct zapi_ipv4 api; |
|
|
if (zclient->redist[ZEBRA_ROUTE_OSPF]) | if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_OSPF], VRF_DEFAULT)) |
{ |
{ |
|
api.vrf_id = VRF_DEFAULT; |
api.type = ZEBRA_ROUTE_OSPF; |
api.type = ZEBRA_ROUTE_OSPF; |
api.flags = ZEBRA_FLAG_BLACKHOLE; |
api.flags = ZEBRA_FLAG_BLACKHOLE; |
api.message = 0; |
api.message = 0; |
Line 560 int
|
Line 564 int
|
ospf_is_type_redistributed (int type) |
ospf_is_type_redistributed (int type) |
{ |
{ |
return (DEFAULT_ROUTE_TYPE (type)) ? |
return (DEFAULT_ROUTE_TYPE (type)) ? |
zclient->default_information : zclient->redist[type]; | vrf_bitmap_check (zclient->default_information, VRF_DEFAULT) : \ |
| vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT); |
} |
} |
|
|
int |
int |
Line 594 ospf_redistribute_set (struct ospf *ospf, int type, in
|
Line 599 ospf_redistribute_set (struct ospf *ospf, int type, in
|
ospf->dmetric[type].type = mtype; |
ospf->dmetric[type].type = mtype; |
ospf->dmetric[type].value = mvalue; |
ospf->dmetric[type].value = mvalue; |
|
|
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type); | zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type, VRF_DEFAULT); |
|
|
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
zlog_debug ("Redistribute[%s]: Start Type[%d], Metric[%d]", |
zlog_debug ("Redistribute[%s]: Start Type[%d], Metric[%d]", |
Line 615 ospf_redistribute_unset (struct ospf *ospf, int type)
|
Line 620 ospf_redistribute_unset (struct ospf *ospf, int type)
|
if (!ospf_is_type_redistributed (type)) |
if (!ospf_is_type_redistributed (type)) |
return CMD_SUCCESS; |
return CMD_SUCCESS; |
|
|
zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type); | zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type, VRF_DEFAULT); |
|
|
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
zlog_debug ("Redistribute[%s]: Stop", |
zlog_debug ("Redistribute[%s]: Stop", |
Line 655 ospf_redistribute_default_set (struct ospf *ospf, int
|
Line 660 ospf_redistribute_default_set (struct ospf *ospf, int
|
return CMD_SUCCESS; |
return CMD_SUCCESS; |
} |
} |
|
|
zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient); | zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient, |
| VRF_DEFAULT); |
|
|
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
zlog_debug ("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]", |
zlog_debug ("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]", |
Line 682 ospf_redistribute_default_unset (struct ospf *ospf)
|
Line 688 ospf_redistribute_default_unset (struct ospf *ospf)
|
ospf->dmetric[DEFAULT_ROUTE].type = -1; |
ospf->dmetric[DEFAULT_ROUTE].type = -1; |
ospf->dmetric[DEFAULT_ROUTE].value = -1; |
ospf->dmetric[DEFAULT_ROUTE].value = -1; |
|
|
zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient); | zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient, |
| VRF_DEFAULT); |
|
|
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
zlog_debug ("Redistribute[DEFAULT]: Stop"); |
zlog_debug ("Redistribute[DEFAULT]: Stop"); |
Line 816 ospf_routemap_unset (struct ospf *ospf, int type)
|
Line 823 ospf_routemap_unset (struct ospf *ospf, int type)
|
/* Zebra route add and delete treatment. */ |
/* Zebra route add and delete treatment. */ |
static int |
static int |
ospf_zebra_read_ipv4 (int command, struct zclient *zclient, |
ospf_zebra_read_ipv4 (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_ipv4 api; |
struct zapi_ipv4 api; |
Line 825 ospf_zebra_read_ipv4 (int command, struct zclient *zcl
|
Line 832 ospf_zebra_read_ipv4 (int command, struct zclient *zcl
|
struct prefix_ipv4 p; |
struct prefix_ipv4 p; |
struct external_info *ei; |
struct external_info *ei; |
struct ospf *ospf; |
struct ospf *ospf; |
|
unsigned char plength = 0; |
|
|
s = zclient->ibuf; |
s = zclient->ibuf; |
ifindex = 0; |
ifindex = 0; |
Line 838 ospf_zebra_read_ipv4 (int command, struct zclient *zcl
|
Line 846 ospf_zebra_read_ipv4 (int command, struct zclient *zcl
|
/* IPv4 prefix. */ |
/* IPv4 prefix. */ |
memset (&p, 0, sizeof (struct prefix_ipv4)); |
memset (&p, 0, sizeof (struct prefix_ipv4)); |
p.family = AF_INET; |
p.family = AF_INET; |
p.prefixlen = stream_getc (s); | plength = stream_getc (s); |
| p.prefixlen = MIN(IPV4_MAX_PREFIXLEN, plength); |
stream_get (&p.prefix, s, PSIZE (p.prefixlen)); |
stream_get (&p.prefix, s, PSIZE (p.prefixlen)); |
|
|
if (IPV4_NET127(ntohl(p.prefix.s_addr))) |
if (IPV4_NET127(ntohl(p.prefix.s_addr))) |
Line 918 ospf_zebra_read_ipv4 (int command, struct zclient *zcl
|
Line 927 ospf_zebra_read_ipv4 (int command, struct zclient *zcl
|
|
|
return 0; |
return 0; |
} |
} |
|
|
|
|
|
|
int |
int |
ospf_distribute_list_out_set (struct ospf *ospf, int type, const char *name) |
ospf_distribute_list_out_set (struct ospf *ospf, int type, const char *name) |
{ |
{ |
Line 1000 ospf_distribute_list_update_timer (struct thread *thre
|
Line 1009 ospf_distribute_list_update_timer (struct thread *thre
|
return 0; |
return 0; |
} |
} |
|
|
#define OSPF_DISTRIBUTE_UPDATE_DELAY 5 |
|
|
|
/* Update distribute-list and set timer to apply access-list. */ |
/* Update distribute-list and set timer to apply access-list. */ |
void |
void |
ospf_distribute_list_update (struct ospf *ospf, uintptr_t type) |
ospf_distribute_list_update (struct ospf *ospf, uintptr_t type) |
Line 1018 ospf_distribute_list_update (struct ospf *ospf, uintpt
|
Line 1025 ospf_distribute_list_update (struct ospf *ospf, uintpt
|
|
|
/* Set timer. */ |
/* Set timer. */ |
ospf->t_distribute_update = |
ospf->t_distribute_update = |
thread_add_timer (master, ospf_distribute_list_update_timer, | thread_add_timer_msec (master, ospf_distribute_list_update_timer, |
(void *) type, OSPF_DISTRIBUTE_UPDATE_DELAY); | (void *) type, ospf->min_ls_interval); |
} |
} |
|
|
/* If access-list is updated, apply some check. */ |
/* If access-list is updated, apply some check. */ |
Line 1126 ospf_prefix_list_update (struct prefix_list *plist)
|
Line 1133 ospf_prefix_list_update (struct prefix_list *plist)
|
{ |
{ |
/* Update filter-list in. */ |
/* Update filter-list in. */ |
if (PREFIX_NAME_IN (area)) |
if (PREFIX_NAME_IN (area)) |
if (strcmp (PREFIX_NAME_IN (area), plist->name) == 0) | if (strcmp (PREFIX_NAME_IN (area), prefix_list_name (plist)) == 0) |
{ |
{ |
PREFIX_LIST_IN (area) = |
PREFIX_LIST_IN (area) = |
prefix_list_lookup (AFI_IP, PREFIX_NAME_IN (area)); |
prefix_list_lookup (AFI_IP, PREFIX_NAME_IN (area)); |
Line 1135 ospf_prefix_list_update (struct prefix_list *plist)
|
Line 1142 ospf_prefix_list_update (struct prefix_list *plist)
|
|
|
/* Update filter-list out. */ |
/* Update filter-list out. */ |
if (PREFIX_NAME_OUT (area)) |
if (PREFIX_NAME_OUT (area)) |
if (strcmp (PREFIX_NAME_OUT (area), plist->name) == 0) | if (strcmp (PREFIX_NAME_OUT (area), prefix_list_name (plist)) == 0) |
{ |
{ |
PREFIX_LIST_IN (area) = |
PREFIX_LIST_IN (area) = |
prefix_list_lookup (AFI_IP, PREFIX_NAME_OUT (area)); |
prefix_list_lookup (AFI_IP, PREFIX_NAME_OUT (area)); |
Line 1292 ospf_distance_apply (struct prefix_ipv4 *p, struct osp
|
Line 1299 ospf_distance_apply (struct prefix_ipv4 *p, struct osp
|
return 0; |
return 0; |
} |
} |
|
|
|
static void |
|
ospf_zebra_connected (struct zclient *zclient) |
|
{ |
|
zclient_send_requests (zclient, VRF_DEFAULT); |
|
} |
|
|
void |
void |
ospf_zebra_init () | ospf_zebra_init (struct thread_master *master) |
{ |
{ |
/* Allocate zebra structure. */ |
/* Allocate zebra structure. */ |
zclient = zclient_new (); | zclient = zclient_new (master); |
zclient_init (zclient, ZEBRA_ROUTE_OSPF); |
zclient_init (zclient, ZEBRA_ROUTE_OSPF); |
|
zclient->zebra_connected = ospf_zebra_connected; |
zclient->router_id_update = ospf_router_id_update_zebra; |
zclient->router_id_update = ospf_router_id_update_zebra; |
zclient->interface_add = ospf_interface_add; |
zclient->interface_add = ospf_interface_add; |
zclient->interface_delete = ospf_interface_delete; |
zclient->interface_delete = ospf_interface_delete; |