[ovs-dev] [PATCH] tunnel: Zero keys if marked as not present.
Pravin Shelar
pshelar at nicira.com
Wed Nov 7 04:04:01 UTC 2012
On Tue, Nov 6, 2012 at 6:32 PM, Jesse Gross <jesse at nicira.com> wrote:
> If a key used to find a port then we mark it as being not present
> (previously this was accomplished by setting it to zero). However,
> we also still pass the key to userspace which could lead to an
> inconsistent state. This also zeros out the key as before in order
> to make our reported results consistent.
>
>
I am not sure why is it inconsistent, zeroing key can not mean it is not
present since zero is valid key. only key_present flag can be used for
check and I think it is set correctly.
> Signed-off-by: Jesse Gross <jesse at nicira.com>
> ---
> datapath/vport-capwap.c | 4 +++-
> datapath/vport-gre.c | 17 ++++++++++-------
> 2 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/datapath/vport-capwap.c b/datapath/vport-capwap.c
> index 8a89180..5f31732 100644
> --- a/datapath/vport-capwap.c
> +++ b/datapath/vport-capwap.c
> @@ -334,8 +334,10 @@ static int capwap_rcv(struct sock *sk, struct sk_buff
> *skb)
> }
>
> if (key_present && mutable->key.daddr &&
> - !(mutable->flags & TNL_F_IN_KEY_MATCH))
> + !(mutable->flags & TNL_F_IN_KEY_MATCH)) {
> key_present = false;
> + key = 0;
> + }
>
> tnl_tun_key_init(&tun_key, iph, key, key_present ? OVS_TNL_F_KEY :
> 0);
> OVS_CB(skb)->tun_key = &tun_key;
> diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c
> index 7f8bc9a..3c13499 100644
> --- a/datapath/vport-gre.c
> +++ b/datapath/vport-gre.c
> @@ -353,15 +353,16 @@ static bool check_checksum(struct sk_buff *skb)
> }
>
> static u32 gre_flags_to_tunnel_flags(const struct tnl_mutable_config
> *mutable,
> - __be16 gre_flags)
> + __be16 gre_flags, __be64 *key)
> {
> u32 tunnel_flags = 0;
>
> if (gre_flags & GRE_KEY) {
> - if (mutable->key.daddr && (mutable->flags &
> TNL_F_IN_KEY_MATCH))
> - tunnel_flags = OVS_TNL_F_KEY;
> - else if (!mutable->key.daddr)
> + if (mutable->flags & TNL_F_IN_KEY_MATCH ||
> + !mutable->key.daddr)
> tunnel_flags = OVS_TNL_F_KEY;
> + else
> + *key = 0;
> }
>
> if (gre_flags & GRE_CSUM)
> @@ -378,7 +379,8 @@ static int gre_rcv(struct sk_buff *skb)
> int hdr_len;
> struct iphdr *iph;
> struct ovs_key_ipv4_tunnel tun_key;
> - __be16 flags;
> + __be16 gre_flags;
> + u32 tnl_flags;
> __be64 key;
> u32 tunnel_type;
>
> @@ -387,7 +389,7 @@ static int gre_rcv(struct sk_buff *skb)
> if (unlikely(!check_checksum(skb)))
> goto error;
>
> - hdr_len = parse_header(ip_hdr(skb), &flags, &key, &tunnel_type);
> + hdr_len = parse_header(ip_hdr(skb), &gre_flags, &key,
> &tunnel_type);
> if (unlikely(hdr_len < 0))
> goto error;
>
> @@ -402,7 +404,8 @@ static int gre_rcv(struct sk_buff *skb)
> goto error;
> }
>
> - tnl_tun_key_init(&tun_key, iph, key,
> gre_flags_to_tunnel_flags(mutable, flags));
> + tnl_flags = gre_flags_to_tunnel_flags(mutable, gre_flags, &key);
> + tnl_tun_key_init(&tun_key, iph, key, tnl_flags);
> OVS_CB(skb)->tun_key = &tun_key;
>
> __skb_pull(skb, hdr_len);
> --
> 1.7.9.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20121106/0042c79b/attachment-0003.html>
More information about the dev
mailing list