Skip to content

Commit e7d911d

Browse files
author
Markus Gothe
committed
bridge: Make Q-in-Q TPID 0x88a8 configurable.
For Q-in-Q in bridge-vlans to work properly, the right TPID needs to be configured on the outer tag. This makes it possible to set the VLAN protocol similiar to how vlan_filtering option is used. Signed-off-by: Markus Gothe <markus.gothe@genexis.eu>
1 parent c612225 commit e7d911d

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

bridge.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum {
4343
BRIDGE_ATTR_HAS_VLANS,
4444
BRIDGE_ATTR_STP_KERNEL,
4545
BRIDGE_ATTR_STP_PROTO,
46+
BRIDGE_ATTR_VLAN_PROTOCOL,
4647
__BRIDGE_ATTR_MAX
4748
};
4849

@@ -66,6 +67,7 @@ static const struct blobmsg_policy bridge_attrs[__BRIDGE_ATTR_MAX] = {
6667
[BRIDGE_ATTR_HAS_VLANS] = { "__has_vlans", BLOBMSG_TYPE_BOOL }, /* internal */
6768
[BRIDGE_ATTR_STP_KERNEL] = { "stp_kernel", BLOBMSG_TYPE_BOOL },
6869
[BRIDGE_ATTR_STP_PROTO] = { "stp_proto", BLOBMSG_TYPE_STRING },
70+
[BRIDGE_ATTR_VLAN_PROTOCOL] = { "vlan_protocol", BLOBMSG_TYPE_INT32 },
6971
};
7072

7173
static const struct uci_blob_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = {
@@ -1129,6 +1131,7 @@ bridge_dump_info(struct device *dev, struct blob_buf *b)
11291131
blobmsg_add_u8(b, "stp_kernel", cfg->stp_kernel);
11301132
if (cfg->stp_proto)
11311133
blobmsg_add_string(b, "stp_proto", cfg->stp_proto);
1134+
blobmsg_add_u32(b, "vlan_protocol", cfg->vlan_protocol);
11321135

11331136
blobmsg_close_table(b, c);
11341137

@@ -1260,6 +1263,12 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb)
12601263

12611264
if ((cur = tb[BRIDGE_ATTR_VLAN_FILTERING]))
12621265
cfg->vlan_filtering = blobmsg_get_bool(cur);
1266+
1267+
if ((cur = tb[BRIDGE_ATTR_VLAN_PROTOCOL]))
1268+
cfg->vlan_protocol = blobmsg_get_u32(cur);
1269+
1270+
if (cfg->vlan_protocol != VLAN_PROTO_8021AD)
1271+
cfg->vlan_protocol = VLAN_PROTO_8021Q;
12631272
}
12641273

12651274
static enum dev_change_type

system-linux.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,7 @@ int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
15581558
}
15591559

15601560
nla_put_u8(msg, IFLA_BR_VLAN_FILTERING, !!cfg->vlan_filtering);
1561+
nla_put_u16(msg, IFLA_BR_VLAN_PROTOCOL, htons(cfg->vlan_protocol));
15611562
nla_put_u16(msg, IFLA_BR_PRIORITY, cfg->priority);
15621563
nla_put_u32(msg, IFLA_BR_HELLO_TIME, sec_to_jiffies(cfg->hello_time));
15631564
nla_put_u32(msg, IFLA_BR_MAX_AGE, sec_to_jiffies(cfg->max_age));

system.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ enum bridge_opt {
116116
BRIDGE_OPT_LAST_MEMBER_INTERVAL = (1 << 4),
117117
};
118118

119+
enum vlan_proto {
120+
VLAN_PROTO_8021Q = 0x8100,
121+
VLAN_PROTO_8021AD = 0x88A8
122+
};
123+
119124
struct bridge_config {
120125
enum bridge_opt flags;
121126
bool stp;
@@ -138,6 +143,7 @@ struct bridge_config {
138143
int max_age;
139144
int hash_max;
140145

146+
enum vlan_proto vlan_protocol;
141147
bool vlan_filtering;
142148
};
143149

@@ -166,11 +172,6 @@ struct veth_config {
166172
unsigned char peer_macaddr[6];
167173
};
168174

169-
enum vlan_proto {
170-
VLAN_PROTO_8021Q = 0x8100,
171-
VLAN_PROTO_8021AD = 0x88A8
172-
};
173-
174175
struct vlan_qos_mapping {
175176
struct vlist_simple_node node; /* entry in vlandev_config->{e,in}gress_qos_mapping_list */
176177
uint32_t from;

0 commit comments

Comments
 (0)