lib: use the correct VRF ID when parsing INTERFACE_LINK_PARAMS messages

Bug found during code inspection.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2019-01-18 16:06:00 -02:00
parent d763789879
commit edc127627d
4 changed files with 11 additions and 9 deletions

View File

@ -219,11 +219,11 @@ static int isis_zebra_if_address_del(int command, struct zclient *client,
} }
static int isis_zebra_link_params(int command, struct zclient *zclient, static int isis_zebra_link_params(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_link_params_read(zclient->ibuf); ifp = zebra_interface_link_params_read(zclient->ibuf, vrf_id);
if (ifp == NULL) if (ifp == NULL)
return 0; return 0;

View File

@ -1495,7 +1495,8 @@ static void link_params_set_value(struct stream *s, struct if_link_params *iflp)
iflp->use_bw = stream_getf(s); iflp->use_bw = stream_getf(s);
} }
struct interface *zebra_interface_link_params_read(struct stream *s) struct interface *zebra_interface_link_params_read(struct stream *s,
vrf_id_t vrf_id)
{ {
struct if_link_params *iflp; struct if_link_params *iflp;
ifindex_t ifindex; ifindex_t ifindex;
@ -1504,7 +1505,7 @@ struct interface *zebra_interface_link_params_read(struct stream *s)
ifindex = stream_getl(s); ifindex = stream_getl(s);
struct interface *ifp = if_lookup_by_index(ifindex, VRF_DEFAULT); struct interface *ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) { if (ifp == NULL) {
flog_err(EC_LIB_ZAPI_ENCODE, flog_err(EC_LIB_ZAPI_ENCODE,
@ -2581,7 +2582,7 @@ static int zclient_read(struct thread *thread)
case ZEBRA_INTERFACE_LINK_PARAMS: case ZEBRA_INTERFACE_LINK_PARAMS:
if (zclient->interface_link_params) if (zclient->interface_link_params)
(*zclient->interface_link_params)(command, zclient, (*zclient->interface_link_params)(command, zclient,
length); length, vrf_id);
break; break;
case ZEBRA_FEC_UPDATE: case ZEBRA_FEC_UPDATE:
if (zclient_debug) if (zclient_debug)

View File

@ -229,7 +229,7 @@ struct zclient {
int (*interface_address_add)(int, struct zclient *, uint16_t, vrf_id_t); int (*interface_address_add)(int, struct zclient *, uint16_t, vrf_id_t);
int (*interface_address_delete)(int, struct zclient *, uint16_t, int (*interface_address_delete)(int, struct zclient *, uint16_t,
vrf_id_t); vrf_id_t);
int (*interface_link_params)(int, struct zclient *, uint16_t); int (*interface_link_params)(int, struct zclient *, uint16_t, vrf_id_t);
int (*interface_bfd_dest_update)(int, struct zclient *, uint16_t, int (*interface_bfd_dest_update)(int, struct zclient *, uint16_t,
vrf_id_t); vrf_id_t);
int (*interface_nbr_address_add)(int, struct zclient *, uint16_t, int (*interface_nbr_address_add)(int, struct zclient *, uint16_t,
@ -564,7 +564,8 @@ extern struct interface *zebra_interface_vrf_update_read(struct stream *s,
extern void zebra_interface_if_set_value(struct stream *, struct interface *); extern void zebra_interface_if_set_value(struct stream *, struct interface *);
extern void zebra_router_id_update_read(struct stream *s, struct prefix *rid); extern void zebra_router_id_update_read(struct stream *s, struct prefix *rid);
extern struct interface *zebra_interface_link_params_read(struct stream *); extern struct interface *zebra_interface_link_params_read(struct stream *s,
vrf_id_t vrf_id);
extern size_t zebra_interface_link_params_write(struct stream *, extern size_t zebra_interface_link_params_write(struct stream *,
struct interface *); struct interface *);
extern int zclient_send_get_label_chunk( extern int zclient_send_get_label_chunk(

View File

@ -340,11 +340,11 @@ static int ospf_interface_address_delete(int command, struct zclient *zclient,
} }
static int ospf_interface_link_params(int command, struct zclient *zclient, static int ospf_interface_link_params(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_link_params_read(zclient->ibuf); ifp = zebra_interface_link_params_read(zclient->ibuf, vrf_id);
if (ifp == NULL) if (ifp == NULL)
return 0; return 0;