Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: sched: only keep the available bits when setting vxlan md->gbp

As we can see from vxlan_build/parse_gbp_hdr(), when processing metadata
on vxlan rx/tx path, only dont_learn/policy_applied/policy_id fields can
be set to or parse from the packet for vxlan gbp option.

So we'd better do the mask when set it in act_tunnel_key and cls_flower.
Otherwise, when users don't know these bits, they may configure with a
value which can never be matched.

Reported-by: Shuang Li <shuali@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xin Long and committed by
David S. Miller
13e6ce98 ff48b622

+7 -1
+3
include/net/vxlan.h
··· 121 121 #define VXLAN_GBP_POLICY_APPLIED (BIT(3) << 16) 122 122 #define VXLAN_GBP_ID_MASK (0xFFFF) 123 123 124 + #define VXLAN_GBP_MASK (VXLAN_GBP_DONT_LEARN | VXLAN_GBP_POLICY_APPLIED | \ 125 + VXLAN_GBP_ID_MASK) 126 + 124 127 /* 125 128 * VXLAN Generic Protocol Extension (VXLAN_F_GPE): 126 129 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+1
net/sched/act_tunnel_key.c
··· 156 156 struct vxlan_metadata *md = dst; 157 157 158 158 md->gbp = nla_get_u32(tb[TCA_TUNNEL_KEY_ENC_OPT_VXLAN_GBP]); 159 + md->gbp &= VXLAN_GBP_MASK; 159 160 } 160 161 161 162 return sizeof(struct vxlan_metadata);
+3 -1
net/sched/cls_flower.c
··· 1175 1175 return -EINVAL; 1176 1176 } 1177 1177 1178 - if (tb[TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP]) 1178 + if (tb[TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP]) { 1179 1179 md->gbp = nla_get_u32(tb[TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP]); 1180 + md->gbp &= VXLAN_GBP_MASK; 1181 + } 1180 1182 1181 1183 return sizeof(*md); 1182 1184 }