From 7ead4932f9ab00fdb8a2cc339b41ee2f5aee441e Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Sun, 5 Jul 2015 20:27:28 +0200 Subject: nft: allow stacking vlan header on top of ethernet currently 'vlan id 42' or even 'vlan type ip' doesn't work since we expect ethernet header but get vlan. So if we want to add another protocol header to the same base, we attempt to figure out if the new header can fit on top of the existing one (i.e. proto_find_num gives a protocol number when asking to find link between the two). We also annotate protocol description for eth and vlan with the full header size and track the offset from the current base. Otherwise, 'vlan type ip' fetches the protocol field from mac header offset 0, which is some mac address. Instead, we must consider full size of ethernet header. Signed-off-by: Florian Westphal --- src/proto.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/proto.c') diff --git a/src/proto.c b/src/proto.c index d40caebc..b2aeac48 100644 --- a/src/proto.c +++ b/src/proto.c @@ -714,6 +714,7 @@ const struct proto_desc proto_vlan = { .name = "vlan", .base = PROTO_BASE_LL_HDR, .protocol_key = VLANHDR_TYPE, + .length = sizeof(struct vlan_hdr) * BITS_PER_BYTE, .protocols = { PROTO_LINK(__constant_htons(ETH_P_IP), &proto_ip), PROTO_LINK(__constant_htons(ETH_P_ARP), &proto_arp), @@ -783,6 +784,7 @@ const struct proto_desc proto_eth = { .name = "ether", .base = PROTO_BASE_LL_HDR, .protocol_key = ETHHDR_TYPE, + .length = sizeof(struct ether_header) * BITS_PER_BYTE, .protocols = { PROTO_LINK(__constant_htons(ETH_P_IP), &proto_ip), PROTO_LINK(__constant_htons(ETH_P_ARP), &proto_arp), -- cgit v1.2.3