ospfd: don't use if_lookup_by_name_all_vrf

if_lookup_by_name_all_vrf doesn't work correctly with netns VRF backend
as the same index may be used in multiple netns simultaneously.

Use the appropriate VRF when looking for the interface.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2021-10-14 21:06:38 +03:00
parent 198ef12aef
commit 4030e1867b
3 changed files with 8 additions and 4 deletions

View File

@ -72,12 +72,13 @@ void ospf_external_route_remove(struct ospf *ospf, struct prefix_ipv4 *p)
}
/* Add an External info for AS-external-LSA. */
struct external_info *ospf_external_info_new(uint8_t type,
struct external_info *ospf_external_info_new(struct ospf *ospf, uint8_t type,
unsigned short instance)
{
struct external_info *new;
new = XCALLOC(MTYPE_OSPF_EXTERNAL_INFO, sizeof(struct external_info));
new->ospf = ospf;
new->type = type;
new->instance = instance;
new->to_be_processed = 0;
@ -138,7 +139,7 @@ ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance,
}
/* Create new External info instance. */
new = ospf_external_info_new(type, instance);
new = ospf_external_info_new(ospf, type, instance);
new->p = p;
new->ifindex = ifindex;
new->nexthop = nexthop;

View File

@ -29,6 +29,8 @@ struct route_map_set_values {
/* Redistributed external information. */
struct external_info {
struct ospf *ospf;
/* Type of source protocol. */
uint8_t type;
@ -107,7 +109,8 @@ struct ospf_external_aggr_rt {
#define OSPF_ASBR_NSSA_REDIST_UPDATE_DELAY 9
extern void ospf_external_route_remove(struct ospf *, struct prefix_ipv4 *);
extern struct external_info *ospf_external_info_new(uint8_t, unsigned short);
extern struct external_info *ospf_external_info_new(struct ospf *, uint8_t,
unsigned short);
extern void ospf_reset_route_map_set_values(struct route_map_set_values *);
extern int ospf_route_map_set_compare(struct route_map_set_values *,
struct route_map_set_values *);

View File

@ -320,7 +320,7 @@ route_match_interface(void *rule, const struct prefix *prefix, void *object)
struct external_info *ei;
ei = object;
ifp = if_lookup_by_name_all_vrf((char *)rule);
ifp = if_lookup_by_name((char *)rule, ei->ospf->vrf_id);
if (ifp == NULL || ifp->ifindex != ei->ifindex)
return RMAP_NOMATCH;