* [PATCH net 0/2] net: improve vxlan option process in net_sched and lwtunnel
@ 2020-09-13 11:51 Xin Long
2020-09-13 11:51 ` [PATCH net 1/2] net: sched: only keep the available bits when setting vxlan md->gbp Xin Long
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Xin Long @ 2020-09-13 11:51 UTC (permalink / raw)
To: network dev; +Cc: davem, Jamal Hadi Salim, Cong Wang, Jiri Pirko
This patch is to do some mask when setting vxlan option in net_sched
and lwtunnel, so that only available bits can be set on vxlan md gbp.
This would help when users don't know exactly vxlan's gbp bits, and
avoid some mismatch because of some unavailable bits set by users.
Xin Long (2):
net: sched: only keep the available bits when setting vxlan md->gbp
lwtunnel: only keep the available bits when setting vxlan md->gbp
include/net/vxlan.h | 3 +++
net/ipv4/ip_tunnel_core.c | 1 +
net/sched/act_tunnel_key.c | 1 +
net/sched/cls_flower.c | 4 +++-
4 files changed, 8 insertions(+), 1 deletion(-)
--
2.1.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH net 1/2] net: sched: only keep the available bits when setting vxlan md->gbp 2020-09-13 11:51 [PATCH net 0/2] net: improve vxlan option process in net_sched and lwtunnel Xin Long @ 2020-09-13 11:51 ` Xin Long 2020-09-13 11:51 ` [PATCH net 2/2] lwtunnel: " Xin Long 2020-09-14 23:52 ` [PATCH net 0/2] net: improve vxlan option process in net_sched and lwtunnel David Miller 2 siblings, 0 replies; 4+ messages in thread From: Xin Long @ 2020-09-13 11:51 UTC (permalink / raw) To: network dev; +Cc: davem, Jamal Hadi Salim, Cong Wang, Jiri Pirko 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> --- include/net/vxlan.h | 3 +++ net/sched/act_tunnel_key.c | 1 + net/sched/cls_flower.c | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/net/vxlan.h b/include/net/vxlan.h index 3a41627c..08537aa 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -121,6 +121,9 @@ struct vxlanhdr_gbp { #define VXLAN_GBP_POLICY_APPLIED (BIT(3) << 16) #define VXLAN_GBP_ID_MASK (0xFFFF) +#define VXLAN_GBP_MASK (VXLAN_GBP_DONT_LEARN | VXLAN_GBP_POLICY_APPLIED | \ + VXLAN_GBP_ID_MASK) + /* * VXLAN Generic Protocol Extension (VXLAN_F_GPE): * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index 536c4bc..37f1e10 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -156,6 +156,7 @@ tunnel_key_copy_vxlan_opt(const struct nlattr *nla, void *dst, int dst_len, struct vxlan_metadata *md = dst; md->gbp = nla_get_u32(tb[TCA_TUNNEL_KEY_ENC_OPT_VXLAN_GBP]); + md->gbp &= VXLAN_GBP_MASK; } return sizeof(struct vxlan_metadata); diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 19a8fa2..fed18fd 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -1175,8 +1175,10 @@ static int fl_set_vxlan_opt(const struct nlattr *nla, struct fl_flow_key *key, return -EINVAL; } - if (tb[TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP]) + if (tb[TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP]) { md->gbp = nla_get_u32(tb[TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP]); + md->gbp &= VXLAN_GBP_MASK; + } return sizeof(*md); } -- 2.1.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net 2/2] lwtunnel: only keep the available bits when setting vxlan md->gbp 2020-09-13 11:51 [PATCH net 0/2] net: improve vxlan option process in net_sched and lwtunnel Xin Long 2020-09-13 11:51 ` [PATCH net 1/2] net: sched: only keep the available bits when setting vxlan md->gbp Xin Long @ 2020-09-13 11:51 ` Xin Long 2020-09-14 23:52 ` [PATCH net 0/2] net: improve vxlan option process in net_sched and lwtunnel David Miller 2 siblings, 0 replies; 4+ messages in thread From: Xin Long @ 2020-09-13 11:51 UTC (permalink / raw) To: network dev; +Cc: davem, Jamal Hadi Salim, Cong Wang, Jiri Pirko 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 do the mask when set it in lwtunnel, as it does in act_tunnel_key and cls_flower. Signed-off-by: Xin Long <lucien.xin@gmail.com> --- net/ipv4/ip_tunnel_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c index 75c6013..b2ea1a8 100644 --- a/net/ipv4/ip_tunnel_core.c +++ b/net/ipv4/ip_tunnel_core.c @@ -554,6 +554,7 @@ static int ip_tun_parse_opts_vxlan(struct nlattr *attr, attr = tb[LWTUNNEL_IP_OPT_VXLAN_GBP]; md->gbp = nla_get_u32(attr); + md->gbp &= VXLAN_GBP_MASK; info->key.tun_flags |= TUNNEL_VXLAN_OPT; } -- 2.1.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net 0/2] net: improve vxlan option process in net_sched and lwtunnel 2020-09-13 11:51 [PATCH net 0/2] net: improve vxlan option process in net_sched and lwtunnel Xin Long 2020-09-13 11:51 ` [PATCH net 1/2] net: sched: only keep the available bits when setting vxlan md->gbp Xin Long 2020-09-13 11:51 ` [PATCH net 2/2] lwtunnel: " Xin Long @ 2020-09-14 23:52 ` David Miller 2 siblings, 0 replies; 4+ messages in thread From: David Miller @ 2020-09-14 23:52 UTC (permalink / raw) To: lucien.xin; +Cc: netdev, jhs, xiyou.wangcong, jiri From: Xin Long <lucien.xin@gmail.com> Date: Sun, 13 Sep 2020 19:51:49 +0800 > This patch is to do some mask when setting vxlan option in net_sched > and lwtunnel, so that only available bits can be set on vxlan md gbp. > > This would help when users don't know exactly vxlan's gbp bits, and > avoid some mismatch because of some unavailable bits set by users. Series applied, thank you. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-14 23:52 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-09-13 11:51 [PATCH net 0/2] net: improve vxlan option process in net_sched and lwtunnel Xin Long 2020-09-13 11:51 ` [PATCH net 1/2] net: sched: only keep the available bits when setting vxlan md->gbp Xin Long 2020-09-13 11:51 ` [PATCH net 2/2] lwtunnel: " Xin Long 2020-09-14 23:52 ` [PATCH net 0/2] net: improve vxlan option process in net_sched and lwtunnel David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).