@@ -90,6 +90,7 @@ enum datatypes {
TYPE_CT_EVENTBIT,
TYPE_IFNAME,
TYPE_IGMP_TYPE,
+ TYPE_VLANID,
__TYPE_MAX
};
#define TYPE_MAX (__TYPE_MAX - 1)
@@ -264,6 +265,7 @@ extern const struct datatype time_type;
extern const struct datatype boolean_type;
extern const struct datatype priority_type;
extern const struct datatype policy_type;
+extern const struct datatype vlanid_type;
void inet_service_type_print(const struct expr *expr, struct output_ctx *octx);
@@ -71,6 +71,7 @@ static const struct datatype *datatypes[TYPE_MAX + 1] = {
[TYPE_BOOLEAN] = &boolean_type,
[TYPE_IFNAME] = &ifname_type,
[TYPE_IGMP_TYPE] = &igmp_type_type,
+ [TYPE_VLANID] = &vlanid_type,
};
const struct datatype *datatype_lookup(enum datatypes type)
@@ -918,6 +918,15 @@ const struct proto_desc proto_arp = {
#include <net/ethernet.h>
+const struct datatype vlanid_type = {
+ .type = TYPE_VLANID,
+ .name = "vlan_id",
+ .desc = "802.1Q VLAN ID",
+ .byteorder = BYTEORDER_BIG_ENDIAN,
+ .size = 12,
+ .basetype = &integer_type,
+};
+
#define VLANHDR_BITFIELD(__name, __offset, __len) \
HDR_BITFIELD(__name, &integer_type, __offset, __len)
#define VLANHDR_TYPE(__name, __type, __member) \
@@ -938,7 +947,7 @@ const struct proto_desc proto_vlan = {
.templates = {
[VLANHDR_PCP] = VLANHDR_BITFIELD("pcp", 0, 3),
[VLANHDR_CFI] = VLANHDR_BITFIELD("cfi", 3, 1),
- [VLANHDR_VID] = VLANHDR_BITFIELD("id", 4, 12),
+ [VLANHDR_VID] = HDR_BITFIELD("id", &vlanid_type, 4, 12),
[VLANHDR_TYPE] = VLANHDR_TYPE("type", ðertype_type, vlan_type),
},
};
This enables using vlan id in a set or a concatenation. table bridge filter { set dropvlans { type vlan_id elements = { 123 } } chain FORWARD { type filter hook forward priority filter; policy accept; vlan id @dropvlans drop } } Signed-off-by: Michael Braun <michael-dev@fami-braun.de> --- include/datatype.h | 2 ++ src/datatype.c | 1 + src/proto.c | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-)