vswitchd: Instrument lacp_update_ifaces().
[openvswitch] / datapath / tunnel.c
index 08906e4ca1ba4b02561311af5638febfd4cbf087..40577fbd516c26d65b2825544a712b8c27bf5dfc 100644 (file)
@@ -663,7 +663,6 @@ bool tnl_frag_needed(struct vport *vport, const struct tnl_mutable_config *mutab
        }
 #endif
 
-       total_length = min(total_length, mutable->mtu);
        payload_length = total_length - header_length;
 
        nskb = dev_alloc_skb(NET_IP_ALIGN + eth_hdr_len + header_length +
@@ -716,54 +715,57 @@ static bool check_mtu(struct sk_buff *skb,
                      const struct tnl_mutable_config *mutable,
                      const struct rtable *rt, __be16 *frag_offp)
 {
-       int mtu;
-       __be16 frag_off;
+       bool pmtud = mutable->flags & TNL_F_PMTUD;
+       __be16 frag_off = 0;
+       int mtu = 0;
+       unsigned int packet_length = skb->len - ETH_HLEN;
+
+       if (eth_hdr(skb)->h_proto == htons(ETH_P_8021Q))
+               packet_length -= VLAN_HLEN;
+
+       if (pmtud) {
+               frag_off = htons(IP_DF);
 
-       frag_off = (mutable->flags & TNL_F_PMTUD) ? htons(IP_DF) : 0;
-       if (frag_off)
                mtu = dst_mtu(&rt_dst(rt))
                        - ETH_HLEN
                        - mutable->tunnel_hlen
-                       - (eth_hdr(skb)->h_proto == htons(ETH_P_8021Q) ? VLAN_HLEN : 0);
-       else
-               mtu = mutable->mtu;
+                       - (eth_hdr(skb)->h_proto == htons(ETH_P_8021Q) ?
+                               VLAN_HLEN : 0);
+       }
 
        if (skb->protocol == htons(ETH_P_IP)) {
-               struct iphdr *old_iph = ip_hdr(skb);
+               struct iphdr *iph = ip_hdr(skb);
 
-               frag_off |= old_iph->frag_off & htons(IP_DF);
-               mtu = max(mtu, IP_MIN_MTU);
+               frag_off |= iph->frag_off & htons(IP_DF);
 
-               if ((old_iph->frag_off & htons(IP_DF)) &&
-                   mtu < ntohs(old_iph->tot_len)) {
-                       if (tnl_frag_needed(vport, mutable, skb, mtu, OVS_CB(skb)->tun_id))
-                               goto drop;
+               if (pmtud && iph->frag_off & htons(IP_DF)) {
+                       mtu = max(mtu, IP_MIN_MTU);
+
+                       if (packet_length > mtu &&
+                           tnl_frag_needed(vport, mutable, skb, mtu,
+                                           OVS_CB(skb)->tun_id))
+                               return false;
                }
        }
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
        else if (skb->protocol == htons(ETH_P_IPV6)) {
-               unsigned int packet_length = skb->len - ETH_HLEN
-                       - (eth_hdr(skb)->h_proto == htons(ETH_P_8021Q) ? VLAN_HLEN : 0);
-
-               mtu = max(mtu, IPV6_MIN_MTU);
-
                /* IPv6 requires PMTUD if the packet is above the minimum MTU. */
                if (packet_length > IPV6_MIN_MTU)
                        frag_off = htons(IP_DF);
 
-               if (mtu < packet_length) {
-                       if (tnl_frag_needed(vport, mutable, skb, mtu, OVS_CB(skb)->tun_id))
-                               goto drop;
+               if (pmtud) {
+                       mtu = max(mtu, IPV6_MIN_MTU);
+
+                       if (packet_length > mtu &&
+                           tnl_frag_needed(vport, mutable, skb, mtu,
+                                           OVS_CB(skb)->tun_id))
+                               return false;
                }
        }
 #endif
 
        *frag_offp = frag_off;
        return true;
-
-drop:
-       *frag_offp = 0;
-       return false;
 }
 
 static void create_tunnel_header(const struct vport *vport,
@@ -1151,7 +1153,7 @@ int tnl_send(struct vport *vport, struct sk_buff *skb)
        struct dst_entry *unattached_dst = NULL;
        struct tnl_cache *cache;
        int sent_len = 0;
-       __be16 frag_off;
+       __be16 frag_off = 0;
        u8 ttl;
        u8 inner_tos;
        u8 tos;
@@ -1425,7 +1427,6 @@ struct vport *tnl_create(const struct vport_parms *parms,
        }
 
        vport_gen_rand_ether_addr(mutable->eth_addr);
-       mutable->mtu = ETH_DATA_LEN;
 
        get_random_bytes(&initial_frag_id, sizeof(int));
        atomic_set(&tnl_vport->frag_id, initial_frag_id);
@@ -1474,7 +1475,6 @@ int tnl_set_options(struct vport *vport, struct nlattr *options)
        old_mutable = rtnl_dereference(tnl_vport->mutable);
        mutable->seq = old_mutable->seq + 1;
        memcpy(mutable->eth_addr, old_mutable->eth_addr, ETH_ALEN);
-       mutable->mtu = old_mutable->mtu;
 
        /* Parse the others configured by userspace. */
        err = tnl_set_config(options, tnl_vport->tnl_ops, vport, mutable);
@@ -1545,22 +1545,6 @@ int tnl_destroy(struct vport *vport)
        return 0;
 }
 
-int tnl_set_mtu(struct vport *vport, int mtu)
-{
-       struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
-       struct tnl_mutable_config *mutable;
-
-       mutable = kmemdup(rtnl_dereference(tnl_vport->mutable),
-                         sizeof(struct tnl_mutable_config), GFP_KERNEL);
-       if (!mutable)
-               return -ENOMEM;
-
-       mutable->mtu = mtu;
-       assign_config_rcu(vport, mutable);
-
-       return 0;
-}
-
 int tnl_set_addr(struct vport *vport, const unsigned char *addr)
 {
        struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
@@ -1589,12 +1573,6 @@ const unsigned char *tnl_get_addr(const struct vport *vport)
        return rcu_dereference_rtnl(tnl_vport->mutable)->eth_addr;
 }
 
-int tnl_get_mtu(const struct vport *vport)
-{
-       const struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
-       return rcu_dereference_rtnl(tnl_vport->mutable)->mtu;
-}
-
 void tnl_free_linked_skbs(struct sk_buff *skb)
 {
        if (unlikely(!skb))