This avoids the need to calculate the hdr_len for each packet, as was the case before flow-based tunneling was added. It also reduces kernel code.
Signed-off-by: Simon Horman <ho...@verge.net.au> --- v5 * Initial posting --- datapath/tunnel.c | 12 +----------- datapath/tunnel.h | 7 ------- datapath/vport-capwap.c | 22 ++-------------------- datapath/vport-gre.c | 17 ----------------- 4 files changed, 3 insertions(+), 55 deletions(-) diff --git a/datapath/tunnel.c b/datapath/tunnel.c index 1f1705c..a20e032 100644 --- a/datapath/tunnel.c +++ b/datapath/tunnel.c @@ -728,14 +728,6 @@ free_frags: return sent_len; } -static int tunnel_hlen(struct tnl_vport *tnl_vport, struct sk_buff *skb) -{ - int tun_hlen = tnl_vport->tnl_ops->hdr_len(skb); - if (tun_hlen < 0) - return tun_hlen; - return tun_hlen + sizeof(struct iphdr); -} - int ovs_tnl_send(struct vport *vport, struct sk_buff *skb) { struct tnl_vport *tnl_vport = tnl_vport_priv(vport); @@ -807,9 +799,7 @@ int ovs_tnl_send(struct vport *vport, struct sk_buff *skb) skb_dst_drop(skb); skb_clear_rxhash(skb); - tun_hlen = tunnel_hlen(tnl_vport, skb); - if (unlikely(tun_hlen < 0)) - goto error; + tun_hlen = OVS_CB(skb)->tun_key->tun_hdr_len + sizeof(struct iphdr); /* Offloading */ skb = handle_offloads(skb, tun_hlen, rt); diff --git a/datapath/tunnel.h b/datapath/tunnel.h index cbfe83a..96752b8 100644 --- a/datapath/tunnel.h +++ b/datapath/tunnel.h @@ -101,13 +101,6 @@ struct tnl_ops { u8 ipproto; /* The IP protocol for the tunnel. */ /* - * Returns the length of the tunnel header that will be added in - * build_header() (i.e. excludes the IP header). Returns a negative - * error code if the configuration is invalid. - */ - int (*hdr_len)(struct sk_buff *skb); - - /* * Builds the static portion of the tunnel header, which is stored in * the header cache. In general the performance of this function is * not too important as we try to only call it when building the cache diff --git a/datapath/vport-capwap.c b/datapath/vport-capwap.c index 102a207..ddfedec 100644 --- a/datapath/vport-capwap.c +++ b/datapath/vport-capwap.c @@ -155,24 +155,6 @@ static struct inet_frags frag_state = { .secret_interval = CAPWAP_FRAG_SECRET_INTERVAL, }; -static int capwap_hdr_len(struct sk_buff *skb) -{ - int size = CAPWAP_MIN_HLEN; - - /* CAPWAP has no checksums. */ - if (OVS_CB(skb)->tun_key->tun_flags & TNL_F_CSUM) { - return -EINVAL; - - /* if keys are specified, then add WSI field */ - if (OVS_CB(skb)->tun_key->tun_id || - OVS_CB(skb)->tun_key->tun_flags & TNL_F_OUT_KEY_ACTION) - size += sizeof(struct capwaphdr_wsi) + - sizeof(struct capwaphdr_wsi_key); - } - - return size; -} - static void capwap_build_header(const struct vport *vport, struct sk_buff *skb) { struct iphdr *iph = (struct iphdr *)skb->data; @@ -226,7 +208,8 @@ static struct sk_buff *capwap_update_header(const struct vport *vport, udph->len = htons(skb->len - skb_transport_offset(skb)); if (unlikely(skb->len - skb_network_offset(skb) > dst_mtu(dst))) { - unsigned int hlen = skb_transport_offset(skb) + capwap_hdr_len(skb); + unsigned int hlen = skb_transport_offset(skb) + + OVS_CB(skb)->tun_key->tun_hdr_len; skb = fragment(skb, vport, dst, hlen); } @@ -347,7 +330,6 @@ out: static const struct tnl_ops capwap_tnl_ops = { .tunnel_type = TNL_T_PROTO_CAPWAP, .ipproto = IPPROTO_UDP, - .hdr_len = capwap_hdr_len, .build_header = capwap_build_header, .update_header = capwap_update_header, }; diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c index b6a4308..aca9a52 100644 --- a/datapath/vport-gre.c +++ b/datapath/vport-gre.c @@ -45,22 +45,6 @@ struct gre_base_hdr { __be16 protocol; }; -static int gre_hdr_len(struct sk_buff *skb) -{ - int len; - - len = GRE_HEADER_SECTION; - - if (OVS_CB(skb)->tun_key->tun_flags & TNL_F_CSUM) - len += GRE_HEADER_SECTION; - - if (OVS_CB(skb)->tun_key->tun_id || - OVS_CB(skb)->tun_key->tun_flags & TNL_F_OUT_KEY_ACTION) - len += GRE_HEADER_SECTION; - - return len; -} - /* Returns the least-significant 32 bits of a __be64. */ static __be32 be64_get_low32(__be64 x) { @@ -372,7 +356,6 @@ error: static const struct tnl_ops gre_tnl_ops = { .tunnel_type = TNL_T_PROTO_GRE, .ipproto = IPPROTO_GRE, - .hdr_len = gre_hdr_len, .build_header = gre_build_header, .update_header = gre_update_header, }; -- 1.7.10.2.484.gcd07cc5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev