net: l2: Add promiscuous mode to L2 flags when applicable
This allows more bearers than just ethernet to have promiscuous mode support. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
66244a0e67
commit
1f855095b4
|
@ -33,6 +33,9 @@ enum net_l2_flags {
|
|||
|
||||
/** Do not joint solicited node multicast group */
|
||||
NET_L2_MULTICAST_SKIP_JOIN_SOLICIT_NODE = BIT(1),
|
||||
|
||||
/** Is promiscuous mode supported */
|
||||
NET_L2_PROMISC_MODE = BIT(2),
|
||||
};
|
||||
|
||||
struct net_l2 {
|
||||
|
|
|
@ -2382,21 +2382,25 @@ done:
|
|||
|
||||
int net_if_set_promisc(struct net_if *iface)
|
||||
{
|
||||
enum net_l2_flags l2_flags = 0;
|
||||
int ret;
|
||||
|
||||
NET_ASSERT(iface);
|
||||
|
||||
/* This is currently only support for ethernet.
|
||||
* TODO: support also other L2 technologies.
|
||||
*/
|
||||
#if defined(CONFIG_NET_L2_ETHERNET)
|
||||
if (net_if_l2(iface) != &NET_L2_GET_NAME(ETHERNET)) {
|
||||
if (net_if_l2(iface)->get_flags) {
|
||||
l2_flags = net_if_l2(iface)->get_flags(iface);
|
||||
}
|
||||
|
||||
if (!(l2_flags & NET_L2_PROMISC_MODE)) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
ret = net_eth_promisc_mode(iface, true);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
#if defined(CONFIG_NET_L2_ETHERNET)
|
||||
if (net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET)) {
|
||||
ret = net_eth_promisc_mode(iface, true);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#else
|
||||
return -ENOTSUP;
|
||||
|
|
|
@ -939,6 +939,10 @@ void ethernet_init(struct net_if *iface)
|
|||
|
||||
ctx->ethernet_l2_flags = NET_L2_MULTICAST;
|
||||
|
||||
if (net_eth_get_hw_capabilities(iface) & ETHERNET_PROMISC_MODE) {
|
||||
ctx->ethernet_l2_flags |= NET_L2_PROMISC_MODE;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_VLAN)
|
||||
if (!(net_eth_get_hw_capabilities(iface) & ETHERNET_HW_VLAN)) {
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue