The call to tnl_ops->hdr_len should not occur before all options are setup.
 If the call happens earlier, then tunnels may end up using uninitialized
options.  This patch moves the hdr_len call after the output key setup.


diff -ur openvswitch/datapath/tunnel.c openvswitch-gre/datapath/tunnel.c
--- openvswitch/datapath/tunnel.c       2011-02-24 19:16:22.000000000 -0800
+++ openvswitch-gre/datapath/tunnel.c   2011-02-24 00:17:32.000000000 -0800
@@ -1369,12 +1369,6 @@
        if (a[ODP_TUNNEL_ATTR_TTL])
                mutable->ttl = nla_get_u8(a[ODP_TUNNEL_ATTR_TTL]);

-       mutable->tunnel_hlen = tnl_ops->hdr_len(mutable);
-       if (mutable->tunnel_hlen < 0)
-               return mutable->tunnel_hlen;
-
-       mutable->tunnel_hlen += sizeof(struct iphdr);
-
        mutable->tunnel_type = tnl_ops->tunnel_type;
        if (!a[ODP_TUNNEL_ATTR_IN_KEY]) {
                mutable->tunnel_type |= TNL_T_KEY_MATCH;
@@ -1388,6 +1382,12 @@
                mutable->flags |= TNL_F_OUT_KEY_ACTION;
        else
                mutable->out_key = nla_get_be64(a[ODP_TUNNEL_ATTR_OUT_KEY]);
+
+        mutable->tunnel_hlen = tnl_ops->hdr_len(mutable);
+       if (mutable->tunnel_hlen < 0)
+               return mutable->tunnel_hlen;
+
+       mutable->tunnel_hlen += sizeof(struct iphdr);

        old_vport = tnl_find_port(mutable->saddr, mutable->daddr,
                                  mutable->in_key, mutable->tunnel_type,
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev_openvswitch.org

Reply via email to