Skip to content

Commit

Permalink
samples: net: Do not setup VLAN if there is no VLAN interfaces
Browse files Browse the repository at this point in the history
No point trying to initialize VLAN interfaces if the VLAN
interface count is zero.

Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
jukkar authored and kartben committed Jan 31, 2025
1 parent 94361d5 commit 6a19162
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions samples/net/mdns_responder/src/vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ int init_vlan(void)
struct ud user_data;
int ret;

if (CONFIG_NET_VLAN_COUNT == 0) {
LOG_DBG("No VLAN interfaces defined.");
return 0;
}

iface = net_if_get_first_by_type(&NET_L2_GET_NAME(ETHERNET));
if (!iface) {
LOG_ERR("No ethernet interfaces found.");
Expand Down
5 changes: 5 additions & 0 deletions samples/net/sockets/echo_client/src/vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ int init_vlan(void)
struct ud ud;
int ret;

if (CONFIG_NET_VLAN_COUNT == 0) {
LOG_DBG("No VLAN interfaces defined.");
return 0;
}

iface = net_if_get_first_by_type(&NET_L2_GET_NAME(ETHERNET));
if (!iface) {
LOG_ERR("No ethernet interfaces found.");
Expand Down
5 changes: 5 additions & 0 deletions samples/net/sockets/echo_server/src/vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ int init_vlan(void)
struct ud ud;
int ret;

if (CONFIG_NET_VLAN_COUNT == 0) {
LOG_DBG("No VLAN interfaces defined.");
return 0;
}

memset(&ud, 0, sizeof(ud));

net_if_foreach(iface_cb, &ud);
Expand Down
5 changes: 5 additions & 0 deletions samples/net/sockets/txtime/src/vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ int init_vlan(void)
struct ud ud;
int ret;

if (CONFIG_NET_VLAN_COUNT == 0) {
LOG_DBG("No VLAN interfaces defined.");
return 0;
}

iface = net_if_get_first_by_type(&NET_L2_GET_NAME(ETHERNET));
if (!iface) {
LOG_ERR("No ethernet interfaces found.");
Expand Down

0 comments on commit 6a19162

Please sign in to comment.