Skip to content
Merged
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 modules/dhcp/control/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int dhcp_configure_interface(struct dhcp_client *client) {
if (iface == NULL)
return errno_set(ENODEV);

if (iface_get_eth_addr(iface->id, &mac) < 0 && errno != EOPNOTSUPP)
if (iface_get_eth_addr(iface, &mac) < 0 && errno != EOPNOTSUPP)
return -errno;

if (client->subnet_mask == 0) {
Expand Down
2 changes: 1 addition & 1 deletion modules/dhcp/control/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static struct rte_mbuf *dhcp_build_packet_common(
return NULL;
}

if (iface_get_eth_addr(iface_id, &mac) < 0) {
if (iface_get_eth_addr(iface, &mac) < 0) {
LOG(ERR, "%s: failed to get MAC for iface %u", caller, iface_id);
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/infra/api/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static struct api_out iface_add(const void *request, struct api_ctx *) {
return api_out(errno, 0, NULL);

if ((resp = malloc(sizeof(*resp))) == NULL) {
iface_destroy(iface->id);
iface_destroy(iface);
return api_out(ENOMEM, 0, NULL);
}

Expand All @@ -57,7 +57,7 @@ static struct api_out iface_del(const void *request, struct api_ctx *) {
if (iface->type == GR_IFACE_TYPE_LOOPBACK)
return api_out(EINVAL, 0, NULL);

ret = iface_destroy(req->iface_id);
ret = iface_destroy(iface);

return api_out(-ret, 0, NULL);
}
Expand Down
22 changes: 11 additions & 11 deletions modules/infra/control/bond.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

static int
bond_all_member_add_mac(const struct iface_info_bond *bond, const struct rte_ether_addr *mac) {
const struct iface *member;
struct iface *member;

for (uint8_t i = 0; i < bond->n_members; i++) {
member = bond->members[i].iface;
if (iface_add_eth_addr(member->id, mac) < 0)
if (iface_add_eth_addr(member, mac) < 0)
return errno_set(errno);
}

Expand All @@ -27,11 +27,11 @@ bond_all_member_add_mac(const struct iface_info_bond *bond, const struct rte_eth

static int
bond_all_member_del_mac(const struct iface_info_bond *bond, const struct rte_ether_addr *mac) {
const struct iface *member;
struct iface *member;

for (uint8_t i = 0; i < bond->n_members; i++) {
member = bond->members[i].iface;
if (iface_del_eth_addr(member->id, mac) < 0 && errno != ENOENT)
if (iface_del_eth_addr(member, mac) < 0 && errno != ENOENT)
return errno_set(errno);
}

Expand Down Expand Up @@ -104,7 +104,7 @@ static int bond_mtu_set(struct iface *iface, uint16_t mtu) {
member = &bond->members[i];
if (member->iface->mtu == mtu)
continue;
if ((ret = iface_set_mtu(member->iface->id, mtu)) < 0)
if ((ret = iface_set_mtu(member->iface, mtu)) < 0)
return ret;
}

Expand All @@ -117,15 +117,15 @@ static int bond_all_members_set_flag(
struct iface *iface,
gr_iface_flags_t flag,
bool enabled,
int (*func)(uint16_t, bool)
int (*func)(struct iface *, bool)
) {
struct iface_info_bond *bond = iface_info_bond(iface);
const struct iface *member;
int ret;

for (uint8_t i = 0; i < bond->n_members; i++) {
member = bond->members[i].iface;
if ((ret = func(member->id, enabled)) < 0)
if ((ret = func((struct iface *)member, enabled)) < 0)
return ret;
}

Expand Down Expand Up @@ -172,7 +172,7 @@ static void bond_fini_old_members(const struct iface *iface, const struct gr_ifa
struct iface_info_port *port;

for (uint8_t i = 0; i < bond->n_members; i++) {
const struct iface *member = bond->members[i].iface;
struct iface *member = bond->members[i].iface;

for (uint8_t j = 0; j < new->n_members; j++) {
if (new->members[j].iface_id == member->id)
Expand All @@ -181,14 +181,14 @@ static void bond_fini_old_members(const struct iface *iface, const struct gr_ifa

LOG(DEBUG, "removing %s from bond %s", member->name, iface->name);
gr_vec_foreach_ref (struct rte_ether_addr *mac, bond->extra_macs) {
if (iface_del_eth_addr(member->id, mac) < 0 && errno != ENOENT) {
if (iface_del_eth_addr(member, mac) < 0 && errno != ENOENT) {
LOG(WARNING,
"failed to unconfigure mac address on member %s: %s",
member->name,
strerror(errno));
}
}
if (iface_del_eth_addr(member->id, &bond->mac) < 0 && errno != ENOENT) {
if (iface_del_eth_addr(member, &bond->mac) < 0 && errno != ENOENT) {
LOG(WARNING,
"failed to unconfigure mac address on member %s: %s",
member->name,
Expand Down Expand Up @@ -357,7 +357,7 @@ static int bond_reconfig(
struct rte_ether_addr mac;
if (rte_is_zero_ether_addr(&api->mac)) {
const struct iface *primary = bond->members[bond->primary_member].iface;
if (iface_get_eth_addr(primary->id, &mac) < 0)
if (iface_get_eth_addr(primary, &mac) < 0)
return errno_set(errno);
} else {
mac = api->mac;
Expand Down
6 changes: 3 additions & 3 deletions modules/infra/control/ctlplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void iface_cp_tx(struct rte_mbuf *m, const struct control_output_drain *drain) {
// The user messed up and removed the tap interface
// release resources on our side to try to recover
if (errno == EBADF) {
iface_destroy(d->iface->id);
iface_destroy((struct iface *)d->iface);
}
LOG(ERR, "write to tap device failed %s", strerror(errno));
}
Expand Down Expand Up @@ -114,7 +114,7 @@ static void iface_cp_poll(evutil_socket_t, short reason, void *ev_iface) {

if (reason & EV_CLOSED) {
LOG(ERR, "tap device %s deleted", iface->name);
iface_destroy(iface->id);
iface_destroy(iface);
return;
}

Expand Down Expand Up @@ -402,7 +402,7 @@ static void cp_update(struct iface *iface) {
LOG(ERR, "ioctl(SIOCGIFHWADDR) %s", strerror(errno));
goto err;
}
iface_get_eth_addr(iface->id, &mac);
iface_get_eth_addr(iface, &mac);
memcpy(ifr.ifr_hwaddr.sa_data, mac.addr_bytes, sizeof(mac));
if (ioctl(ioctl_sock, SIOCSIFHWADDR, &ifr) < 0) {
LOG(ERR, "ioctl(SIOCSIFHWADDR) %s", strerror(errno));
Expand Down
2 changes: 1 addition & 1 deletion modules/infra/control/gr_bond.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define MEMBERS_MAX_LEN ARRAY_DIM(((struct gr_iface_info_bond *)0)->members)

struct bond_member {
const struct iface *iface;
struct iface *iface;
bool active;
bool need_to_transmit; // Need to send immediately
clock_t next_tx; // Next time we need to send a LACP packet
Expand Down
16 changes: 8 additions & 8 deletions modules/infra/control/gr_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ int iface_reconfig(
const struct gr_iface *conf,
const void *api_info
);
int iface_destroy(uint16_t ifid);
int iface_destroy(struct iface *);
struct iface *iface_from_id(uint16_t ifid);
void iface_add_subinterface(struct iface *parent, struct iface *sub);
void iface_del_subinterface(struct iface *parent, struct iface *sub);
int iface_get_eth_addr(uint16_t ifid, struct rte_ether_addr *);
int iface_set_eth_addr(uint16_t ifid, const struct rte_ether_addr *);
int iface_add_eth_addr(uint16_t ifid, const struct rte_ether_addr *);
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_get_eth_addr(const struct iface *, struct rte_ether_addr *);
int iface_set_eth_addr(struct iface *, const struct rte_ether_addr *);
int iface_add_eth_addr(struct iface *, const struct rte_ether_addr *);
int iface_del_eth_addr(struct iface *, const struct rte_ether_addr *);
int iface_set_mtu(struct iface *, uint16_t mtu);
int iface_set_up_down(struct iface *, bool up);
int iface_set_promisc(struct iface *, bool enabled);
uint16_t ifaces_count(gr_iface_type_t type_id);
struct iface *iface_next(gr_iface_type_t type_id, const struct iface *prev);

Expand Down
Loading