Skip to content

Commit

Permalink
wireless: add network_vlan config attribute
Browse files Browse the repository at this point in the history
This can be used to make a wireless interface/vlan a tagged member of extra VLANs.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 committed Jun 21, 2023
1 parent 077e05f commit 40fad91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions wireless.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static const struct uci_blob_param_list wdev_param = {
enum {
VIF_ATTR_DISABLED,
VIF_ATTR_NETWORK,
VIF_ATTR_NETWORK_VLAN,
VIF_ATTR_ISOLATE,
VIF_ATTR_MODE,
VIF_ATTR_PROXYARP,
Expand All @@ -72,6 +73,7 @@ enum {
static const struct blobmsg_policy vif_policy[__VIF_ATTR_MAX] = {
[VIF_ATTR_DISABLED] = { .name = "disabled", .type = BLOBMSG_TYPE_BOOL },
[VIF_ATTR_NETWORK] = { .name = "network", .type = BLOBMSG_TYPE_ARRAY },
[VIF_ATTR_NETWORK_VLAN] = { .name = "network_vlan", .type = BLOBMSG_TYPE_ARRAY },
[VIF_ATTR_ISOLATE] = { .name = "isolate", .type = BLOBMSG_TYPE_BOOL },
[VIF_ATTR_MODE] = { .name = "mode", .type = BLOBMSG_TYPE_STRING },
[VIF_ATTR_PROXYARP] = { .name = "proxy_arp", .type = BLOBMSG_TYPE_BOOL },
Expand All @@ -86,6 +88,7 @@ static const struct uci_blob_param_list vif_param = {
enum {
VLAN_ATTR_DISABLED,
VLAN_ATTR_NETWORK,
VLAN_ATTR_NETWORK_VLAN,
VLAN_ATTR_ISOLATE,
VLAN_ATTR_MCAST_TO_UCAST,
__VLAN_ATTR_MAX,
Expand All @@ -94,6 +97,7 @@ enum {
static const struct blobmsg_policy vlan_policy[__VLAN_ATTR_MAX] = {
[VLAN_ATTR_DISABLED] = { .name = "disabled", .type = BLOBMSG_TYPE_BOOL },
[VLAN_ATTR_NETWORK] = { .name = "network", .type = BLOBMSG_TYPE_ARRAY },
[VLAN_ATTR_NETWORK_VLAN] = { .name = "network_vlan", .type = BLOBMSG_TYPE_ARRAY },
[VLAN_ATTR_ISOLATE] = { .name = "isolate", .type = BLOBMSG_TYPE_BOOL },
[VLAN_ATTR_MCAST_TO_UCAST] = { .name = "multicast_to_unicast", .type = BLOBMSG_TYPE_BOOL },
};
Expand Down Expand Up @@ -363,7 +367,7 @@ static void wireless_interface_handle_link(struct wireless_interface *vif, const
if (!iface)
continue;

interface_handle_link(iface, ifname, NULL, up, true);
interface_handle_link(iface, ifname, vif->network_vlan, up, true);
}
}

Expand Down Expand Up @@ -395,7 +399,7 @@ static void wireless_vlan_handle_link(struct wireless_vlan *vlan, bool up)
if (!iface)
continue;

interface_handle_link(iface, vlan->ifname, NULL, up, true);
interface_handle_link(iface, vlan->ifname, vlan->network_vlan, up, true);
}
}

Expand Down Expand Up @@ -820,6 +824,9 @@ wireless_interface_init_config(struct wireless_interface *vif)
if ((cur = tb[VIF_ATTR_NETWORK]))
vif->network = cur;

if ((cur = tb[VIF_ATTR_NETWORK_VLAN]))
vif->network_vlan = cur;

cur = tb[VIF_ATTR_MODE];
vif->ap_mode = cur && !strcmp(blobmsg_get_string(cur), "ap");

Expand Down Expand Up @@ -890,6 +897,9 @@ wireless_vlan_init_config(struct wireless_vlan *vlan)
if ((cur = tb[VLAN_ATTR_NETWORK]))
vlan->network = cur;

if ((cur = tb[VLAN_ATTR_NETWORK_VLAN]))
vlan->network_vlan = cur;

cur = tb[VLAN_ATTR_ISOLATE];
if (cur)
vlan->isolate = blobmsg_get_bool(cur);
Expand Down
2 changes: 2 additions & 0 deletions wireless.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct wireless_interface {

const char *ifname;
struct blob_attr *network;
struct blob_attr *network_vlan;
bool proxyarp;
bool isolate;
bool ap_mode;
Expand All @@ -107,6 +108,7 @@ struct wireless_vlan {

const char *ifname;
struct blob_attr *network;
struct blob_attr *network_vlan;
int multicast_to_unicast;
bool isolate;
};
Expand Down

0 comments on commit 40fad91

Please sign in to comment.