Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frr/if_grout.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static uint64_t gr_if_flags_to_netlink(struct gr_iface *gr_if, enum zebra_link_t
frr_if_flags |= IFF_UP;
if (gr_if->base.flags & GR_IFACE_F_PROMISC)
frr_if_flags |= IFF_PROMISC;
if (gr_if->base.flags & GR_IFACE_F_ALLMULTI)
if (gr_if->base.state & GR_IFACE_S_ALLMULTI)
frr_if_flags |= IFF_ALLMULTI;
if (gr_if->base.state & GR_IFACE_S_RUNNING)
frr_if_flags |= IFF_RUNNING | IFF_LOWER_UP;
Expand Down
9 changes: 4 additions & 5 deletions modules/infra/api/gr_infra.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@ typedef enum : uint8_t {
typedef enum : uint16_t {
GR_IFACE_F_UP = GR_BIT16(0),
GR_IFACE_F_PROMISC = GR_BIT16(1),
GR_IFACE_F_ALLMULTI = GR_BIT16(2),
GR_IFACE_F_PACKET_TRACE = GR_BIT16(3),
GR_IFACE_F_SNAT_STATIC = GR_BIT16(4),
GR_IFACE_F_SNAT_DYNAMIC = GR_BIT16(5),
GR_IFACE_F_PACKET_TRACE = GR_BIT16(2),
GR_IFACE_F_SNAT_STATIC = GR_BIT16(3),
GR_IFACE_F_SNAT_DYNAMIC = GR_BIT16(4),
} gr_iface_flags_t;

// Interface state flags
typedef enum : uint16_t {
GR_IFACE_S_RUNNING = GR_BIT16(0),
GR_IFACE_S_PROMISC_FIXED = GR_BIT16(1),
GR_IFACE_S_ALLMULTI_FIXED = GR_BIT16(2),
GR_IFACE_S_ALLMULTI = GR_BIT16(2),
} gr_iface_state_t;

// Interface reconfig attributes
Expand Down
8 changes: 5 additions & 3 deletions modules/infra/cli/gr_cli_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ int complete_iface_names(
#define INTERFACE_SET_CTX(root) \
CLI_CONTEXT(root, INTERFACE_ARG, CTX_ARG("set", "Modify an existing interface."))

#define IFACE_ATTRS_CMD "(up|down),(promisc PROMISC),(allmulti ALLMULTI),(mtu MTU),(vrf VRF)"
#define IFACE_ATTRS_CMD "(up|down),(promisc PROMISC),(mtu MTU),(vrf VRF)"

#define IFACE_ATTRS_ARGS \
with_help("Set the interface UP.", ec_node_str("up", "up")), \
with_help("Enable/disable promiscuous mode.", ec_node_re("PROMISC", "on|off")), \
with_help("Enable/disable all-multicast mode.", ec_node_re("ALLMULTI", "on|off")), \
with_help( \
"Enable/disable promiscuous mode.", \
EC_NODE_OR("PROMISC", ec_node_str("", "on"), ec_node_str("", "off")) \
), \
with_help("Set the interface DOWN.", ec_node_str("down", "down")), \
with_help( \
"Maximum transmission unit size.", \
Expand Down
15 changes: 2 additions & 13 deletions modules/infra/cli/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ static ssize_t iface_flags_format(char *buf, size_t len, const struct gr_iface *
SAFE_BUF(snprintf, len, " promisc(fixed)");
else if (iface->flags & GR_IFACE_F_PROMISC)
SAFE_BUF(snprintf, len, " promisc");
if (iface->state & GR_IFACE_S_ALLMULTI_FIXED)
SAFE_BUF(snprintf, len, " allmulti(fixed)");
else if (iface->flags & GR_IFACE_F_ALLMULTI)
if (iface->state & GR_IFACE_S_ALLMULTI)
SAFE_BUF(snprintf, len, " allmulti");
if (iface->flags & GR_IFACE_F_PACKET_TRACE)
SAFE_BUF(snprintf, len, " tracing");
Expand All @@ -149,7 +147,7 @@ uint64_t parse_iface_args(
size_t info_size,
bool update
) {
const char *name, *promisc, *allmulti;
const char *name, *promisc;
uint64_t set_attrs = 0;

name = arg_str(p, "NAME");
Expand Down Expand Up @@ -187,15 +185,6 @@ uint64_t parse_iface_args(
set_attrs |= GR_IFACE_SET_FLAGS;
}

allmulti = arg_str(p, "ALLMULTI");
if (allmulti != NULL && strcmp(allmulti, "on") == 0) {
iface->flags |= GR_IFACE_F_ALLMULTI;
set_attrs |= GR_IFACE_SET_FLAGS;
} else if (allmulti != NULL && strcmp(allmulti, "off") == 0) {
iface->flags &= ~GR_IFACE_F_ALLMULTI;
set_attrs |= GR_IFACE_SET_FLAGS;
}

if (arg_u16(p, "MTU", &iface->mtu) == 0)
set_attrs |= GR_IFACE_SET_MTU;

Expand Down
5 changes: 0 additions & 5 deletions modules/infra/control/bond.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ static int bond_promisc_set(struct iface *iface, bool enabled) {
return bond_all_members_set_flag(iface, GR_IFACE_F_PROMISC, enabled, iface_set_promisc);
}

static int bond_allmulti_set(struct iface *iface, bool enabled) {
return bond_all_members_set_flag(iface, GR_IFACE_F_ALLMULTI, enabled, iface_set_allmulti);
}

static int bond_vlan_add(struct iface *iface, uint16_t vlan_id) {
struct iface_info_bond *bond = iface_info_bond(iface);
const struct iface *member;
Expand Down Expand Up @@ -369,7 +365,6 @@ static struct iface_type iface_type_bond = {
.del_eth_addr = bond_mac_del,
.set_mtu = bond_mtu_set,
.set_promisc = bond_promisc_set,
.set_allmulti = bond_allmulti_set,
.add_vlan = bond_vlan_add,
.del_vlan = bond_vlan_del,
.to_api = bond_to_api,
Expand Down
2 changes: 0 additions & 2 deletions modules/infra/control/gr_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ struct iface_type {
int (*set_up_down)(struct iface *, bool up);
int (*set_mtu)(struct iface *, uint16_t mtu);
int (*set_promisc)(struct iface *, bool enabled);
int (*set_allmulti)(struct iface *, bool enabled);
int (*add_vlan)(struct iface *, uint16_t vlan_id);
int (*del_vlan)(struct iface *, uint16_t vlan_id);
void (*to_api)(void *api_info, const struct iface *);
Expand Down Expand Up @@ -77,7 +76,6 @@ int iface_del_eth_addr(uint16_t ifid, const struct rte_ether_addr *);
int iface_set_mtu(uint16_t ifid, uint16_t mtu);
int iface_set_up_down(uint16_t ifid, bool up);
int iface_set_promisc(uint16_t ifid, bool enabled);
int iface_set_allmulti(uint16_t ifid, bool enabled);
int iface_add_vlan(uint16_t ifid, uint16_t vlan_id);
int iface_del_vlan(uint16_t ifid, uint16_t vlan_id);
uint16_t ifaces_count(gr_iface_type_t type_id);
Expand Down
20 changes: 10 additions & 10 deletions modules/infra/control/gr_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
#include <stdint.h>
#include <sys/queue.h>

typedef enum : uint8_t {
typedef enum {
MAC_FILTER_F_UNSUPP = GR_BIT8(0),
MAC_FILTER_F_NOSPC = GR_BIT8(1),
MAC_FILTER_F_ALL = GR_BIT8(2),
} mac_filter_flags_t;

struct mac_filter {
mac_filter_flags_t flags;
uint8_t count;
uint8_t hw_limit;
uint16_t refcnt[RTE_ETH_NUM_RECEIVE_MAC_ADDR];
struct rte_ether_addr mac[RTE_ETH_NUM_RECEIVE_MAC_ADDR];
struct port_mac {
uint16_t refcnt;
struct rte_ether_addr mac;
};

GR_IFACE_INFO(GR_IFACE_TYPE_PORT, iface_info_port, {
Expand All @@ -35,8 +31,12 @@ GR_IFACE_INFO(GR_IFACE_TYPE_PORT, iface_info_port, {
struct rte_mempool *pool;
char *devargs;
uint32_t pool_size;
struct mac_filter ucast_filter;
struct mac_filter mcast_filter;
struct {
mac_filter_flags_t flags;
unsigned hw_limit;
unsigned count;
struct port_mac macs[RTE_ETH_NUM_RECEIVE_MAC_ADDR];
} filter;
});

uint32_t port_get_rxq_buffer_us(uint16_t port_id, uint16_t rxq_id);
Expand Down
23 changes: 0 additions & 23 deletions modules/infra/control/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ struct iface *iface_create(const struct gr_iface *conf, const void *api_info) {
if (type->set_promisc != NULL
&& type->set_promisc(iface, iface->flags & GR_IFACE_F_PROMISC) < 0)
goto fail;
if (type->set_allmulti != NULL
&& type->set_allmulti(iface, iface->flags & GR_IFACE_F_ALLMULTI) < 0)
goto fail;
if (type->set_up_down != NULL && type->set_up_down(iface, iface->flags & GR_IFACE_F_UP) < 0)
goto fail;

Expand Down Expand Up @@ -211,8 +208,6 @@ int iface_reconfig(
if (set_attrs & GR_IFACE_SET_FLAGS) {
if ((ret = iface_set_promisc(iface->id, conf->flags & GR_IFACE_F_PROMISC)) < 0)
return ret;
if ((ret = iface_set_allmulti(iface->id, conf->flags & GR_IFACE_F_ALLMULTI)) < 0)
return ret;
if ((ret = iface_set_up_down(iface->id, conf->flags & GR_IFACE_F_UP)) < 0)
return ret;
}
Expand Down Expand Up @@ -394,24 +389,6 @@ int iface_set_promisc(uint16_t ifid, bool enabled) {
return 0;
}

int iface_set_allmulti(uint16_t ifid, bool enabled) {
struct iface *iface = iface_from_id(ifid);
const struct iface_type *type;

if (iface == NULL)
return -errno;

type = iface_type_get(iface->type);
assert(type != NULL);
if (type->set_allmulti != NULL)
return type->set_allmulti(iface, enabled);

if (enabled)
return errno_set(EOPNOTSUPP);

return 0;
}

int iface_add_vlan(uint16_t ifid, uint16_t vlan_id) {
struct iface *iface = iface_from_id(ifid);
const struct iface_type *type;
Expand Down
Loading