}
+static void
+mcast_addr_pool_append(struct rte_port *port, struct rte_ether_addr *mc_addr)
+{
+ if (mcast_addr_pool_extend(port) != 0)
+ return;
+ rte_ether_addr_copy(mc_addr, &port->mc_addr_pool[port->mc_addr_nb - 1]);
+}
+
static void
mcast_addr_pool_remove(struct rte_port *port, uint32_t addr_idx)
{
sizeof(struct rte_ether_addr) * (port->mc_addr_nb - addr_idx));
}
-static void
+static int
eth_port_multicast_addr_list_set(portid_t port_id)
{
struct rte_port *port;
port = &ports[port_id];
diag = rte_eth_dev_set_mc_addr_list(port_id, port->mc_addr_pool,
port->mc_addr_nb);
- if (diag == 0)
- return;
- printf("rte_eth_dev_set_mc_addr_list(port=%d, nb=%u) failed. diag=%d\n",
- port->mc_addr_nb, port_id, -diag);
+ if (diag < 0)
+ printf("rte_eth_dev_set_mc_addr_list(port=%d, nb=%u) failed. diag=%d\n",
+ port_id, port->mc_addr_nb, diag);
+
+ return diag;
}
void
}
}
- if (mcast_addr_pool_extend(port) != 0)
- return;
- rte_ether_addr_copy(mc_addr, &port->mc_addr_pool[i]);
- eth_port_multicast_addr_list_set(port_id);
+ mcast_addr_pool_append(port, mc_addr);
+ if (eth_port_multicast_addr_list_set(port_id) < 0)
+ /* Rollback on failure, remove the address from the pool */
+ mcast_addr_pool_remove(port, i);
}
void
}
mcast_addr_pool_remove(port, i);
- eth_port_multicast_addr_list_set(port_id);
+ if (eth_port_multicast_addr_list_set(port_id) < 0)
+ /* Rollback on failure, add the address back into the pool */
+ mcast_addr_pool_append(port, mc_addr);
}
void