Skip to content

Commit

Permalink
flower-New-API-for-fetching-vlan-ethertype-and-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Zetterlund authored and Johan Zetterlund committed Jan 12, 2024
1 parent 062546e commit bcfda88
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/netlink/route/cls/flower.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern int rtnl_flower_set_vlan_prio(struct rtnl_cls *, uint8_t);
extern int rtnl_flower_get_vlan_prio(struct rtnl_cls *, uint8_t *);

extern int rtnl_flower_set_vlan_ethtype(struct rtnl_cls *, uint16_t);
extern int rtnl_flower_get_vlan_ethtype(struct rtnl_cls *, uint16_t *);

extern int rtnl_flower_set_dst_mac(struct rtnl_cls *, unsigned char *,
unsigned char *);
Expand All @@ -50,6 +51,7 @@ extern int rtnl_flower_set_ip_proto(struct rtnl_cls *, uint8_t);
extern int rtnl_flower_get_ip_proto(struct rtnl_cls *, uint8_t *);

extern int rtnl_flower_set_flags(struct rtnl_cls *, int);
extern int rtnl_flower_get_flags(struct rtnl_cls *, int *);

extern int rtnl_flower_append_action(struct rtnl_cls *, struct rtnl_act *);
extern int rtnl_flower_del_action(struct rtnl_cls *, struct rtnl_act *);
Expand Down
42 changes: 42 additions & 0 deletions lib/route/cls/flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,27 @@ int rtnl_flower_set_vlan_ethtype(struct rtnl_cls *cls, uint16_t ethtype)
return 0;
}

/**
* Get vlan ethtype for flower classifier
* @arg cls Flower classifier.
* @arg vet vlan ethtype
* @return 0 on success or a negative error code.
*/
int rtnl_flower_get_vlan_ethtype(struct rtnl_cls *cls, uint16_t *vet)
{
struct rtnl_flower *f;

if (!(f = rtnl_tc_data_peek(TC_CAST(cls))))
return -NLE_INVAL;

if (!(f->cf_mask & FLOWER_ATTR_VLAN_ETH_TYPE))
return -NLE_MISSING_ATTR;

*vet = ntohs(f->cf_vlan_ethtype);

return 0;
}

/**
* Set destination mac address for flower classifier
* @arg cls Flower classifier.
Expand Down Expand Up @@ -923,6 +944,27 @@ int rtnl_flower_set_flags(struct rtnl_cls *cls, int flags)
return 0;
}

/**
* Get flags for flower classifier
* @arg cls Flower classifier.
* @arg flags flags
* @return 0 on success or a negative error code.
*/
int rtnl_flower_get_flags(struct rtnl_cls *cls, int *flags)
{
struct rtnl_flower *f;

if (!(f = rtnl_tc_data_peek(TC_CAST(cls))))
return -NLE_INVAL;

if (!(f->cf_mask & FLOWER_ATTR_FLAGS))
return -NLE_MISSING_ATTR;

*flags = f->cf_flags;

return 0;
}

/** @} */

static struct rtnl_tc_ops flower_ops = {
Expand Down
2 changes: 2 additions & 0 deletions libnl-route-3.sym
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,8 @@ global:
rtnl_tc_set_egress_block;
rtnl_flower_set_ip_proto;
rtnl_flower_get_ip_proto;
rtnl_flower_get_vlan_ethtype;
rtnl_flower_get_flags;
rtnl_nat_get_action;
rtnl_nat_get_flags;
rtnl_nat_get_mask;
Expand Down

0 comments on commit bcfda88

Please sign in to comment.