#include <linux/workqueue.h>
  #include <linux/delay.h>
  #include <linux/pm_runtime.h>
 +#include <linux/gpio.h>
  #include <linux/of.h>
+ #include <linux/of_mdio.h>
  #include <linux/of_net.h>
  #include <linux/of_device.h>
  #include <linux/if_vlan.h>
 
  struct dst_entry *ip6_route_output(struct net *net, const struct sock *sk,
                                    struct flowi6 *fl6)
  {
 +      struct dst_entry *dst;
        int flags = 0;
+       bool any_src;
  
 +      dst = l3mdev_rt6_dst_by_oif(net, fl6);
 +      if (dst)
 +              return dst;
 +
        fl6->flowi6_iif = LOOPBACK_IFINDEX;
  
+       any_src = ipv6_addr_any(&fl6->saddr);
        if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl6->daddr) ||
-           fl6->flowi6_oif)
+           (fl6->flowi6_oif && any_src))
                flags |= RT6_LOOKUP_F_IFACE;
  
-       if (!ipv6_addr_any(&fl6->saddr))
+       if (!any_src)
                flags |= RT6_LOOKUP_F_HAS_SADDR;
        else if (sk)
                flags |= rt6_srcprefs2flags(inet6_sk(sk)->srcprefs);
 
                return -EMSGSIZE;
        }
  
-       if (x->props.mode == XFRM_MODE_TUNNEL &&
-           ((skb->len > mtu && !skb_is_gso(skb)) ||
-               dst_allfrag(skb_dst(skb)))) {
+       if (toobig || dst_allfrag(skb_dst(skb)))
 -              return ip6_fragment(sk, skb,
 -                                  x->outer_mode->afinfo->output_finish);
 +              return ip6_fragment(net, sk, skb,
 +                                  __xfrm6_output_finish);
-       }
+ 
+ skip_frag:
        return x->outer_mode->afinfo->output_finish(sk, skb);
  }
  
 
        return 0;
  }
  
- int ovs_nla_put_egress_tunnel_key(struct sk_buff *skb,
-                                 const struct ip_tunnel_info *egress_tun_info,
-                                 const void *egress_tun_opts)
+ int ovs_nla_put_tunnel_info(struct sk_buff *skb,
+                           struct ip_tunnel_info *tun_info)
  {
-       return __ip_tun_to_nlattr(skb, &egress_tun_info->key,
-                                 egress_tun_opts,
-                                 egress_tun_info->options_len,
-                                 ip_tunnel_info_af(egress_tun_info));
 -      return __ipv4_tun_to_nlattr(skb, &tun_info->key,
 -                                  ip_tunnel_info_opts(tun_info),
 -                                  tun_info->options_len);
++      return __ip_tun_to_nlattr(skb, &tun_info->key,
++                                ip_tunnel_info_opts(tun_info),
++                                tun_info->options_len,
++                                ip_tunnel_info_af(tun_info));
  }
  
  static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match,
 
        .create         = geneve_create,
        .destroy        = ovs_netdev_tunnel_destroy,
        .get_options    = geneve_get_options,
 -      .send           = ovs_netdev_send,
 +      .send           = dev_queue_xmit,
        .owner          = THIS_MODULE,
-       .get_egress_tun_info    = geneve_get_egress_tun_info,
  };
  
  static int __init ovs_geneve_tnl_init(void)
 
  static struct vport_ops ovs_gre_vport_ops = {
        .type           = OVS_VPORT_TYPE_GRE,
        .create         = gre_create,
 -      .send           = ovs_netdev_send,
 +      .send           = dev_queue_xmit,
-       .get_egress_tun_info    = gre_get_egress_tun_info,
        .destroy        = ovs_netdev_tunnel_destroy,
        .owner          = THIS_MODULE,
  };
 
        .create                 = vxlan_create,
        .destroy                = ovs_netdev_tunnel_destroy,
        .get_options            = vxlan_get_options,
 -      .send                   = ovs_netdev_send,
 +      .send                   = dev_queue_xmit,
-       .get_egress_tun_info    = vxlan_get_egress_tun_info,
  };
  
  static int __init ovs_vxlan_tnl_init(void)
 
        call_rcu(&vport->rcu, free_vport_rcu);
  }
  EXPORT_SYMBOL_GPL(ovs_vport_deferred_free);
- int ovs_tunnel_get_egress_info(struct dp_upcall_info *upcall,
-                              struct net *net,
-                              struct sk_buff *skb,
-                              u8 ipproto,
-                              __be16 tp_src,
-                              __be16 tp_dst)
- {
-       struct ip_tunnel_info *egress_tun_info = upcall->egress_tun_info;
-       const struct ip_tunnel_info *tun_info = skb_tunnel_info(skb);
-       const struct ip_tunnel_key *tun_key;
-       u32 skb_mark = skb->mark;
-       struct rtable *rt;
-       struct flowi4 fl;
- 
-       if (unlikely(!tun_info))
-               return -EINVAL;
-       if (ip_tunnel_info_af(tun_info) != AF_INET)
-               return -EINVAL;
- 
-       tun_key = &tun_info->key;
- 
-       /* Route lookup to get srouce IP address.
-        * The process may need to be changed if the corresponding process
-        * in vports ops changed.
-        */
-       rt = ovs_tunnel_route_lookup(net, tun_key, skb_mark, &fl, ipproto);
-       if (IS_ERR(rt))
-               return PTR_ERR(rt);
- 
-       ip_rt_put(rt);
- 
-       /* Generate egress_tun_info based on tun_info,
-        * saddr, tp_src and tp_dst
-        */
-       ip_tunnel_key_init(&egress_tun_info->key,
-                          fl.saddr, tun_key->u.ipv4.dst,
-                          tun_key->tos,
-                          tun_key->ttl,
-                          tp_src, tp_dst,
-                          tun_key->tun_id,
-                          tun_key->tun_flags);
-       egress_tun_info->options_len = tun_info->options_len;
-       egress_tun_info->mode = tun_info->mode;
-       upcall->egress_tun_opts = ip_tunnel_info_opts(egress_tun_info);
-       return 0;
- }
- EXPORT_SYMBOL_GPL(ovs_tunnel_get_egress_info);
- 
- int ovs_vport_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
-                                 struct dp_upcall_info *upcall)
- {
-       /* get_egress_tun_info() is only implemented on tunnel ports. */
-       if (unlikely(!vport->ops->get_egress_tun_info))
-               return -EINVAL;
- 
-       return vport->ops->get_egress_tun_info(vport, skb, upcall);
- }
- 
 +
 +static unsigned int packet_length(const struct sk_buff *skb)
 +{
 +      unsigned int length = skb->len - ETH_HLEN;
 +
 +      if (skb->protocol == htons(ETH_P_8021Q))
 +              length -= VLAN_HLEN;
 +
 +      return length;
 +}
 +
 +void ovs_vport_send(struct vport *vport, struct sk_buff *skb)
 +{
 +      int mtu = vport->dev->mtu;
 +
 +      if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) {
 +              net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n",
 +                                   vport->dev->name,
 +                                   packet_length(skb), mtu);
 +              vport->dev->stats.tx_errors++;
 +              goto drop;
 +      }
 +
 +      skb->dev = vport->dev;
 +      vport->ops->send(skb);
 +      return;
 +
 +drop:
 +      kfree_skb(skb);
 +}
 
        int (*set_options)(struct vport *, struct nlattr *);
        int (*get_options)(const struct vport *, struct sk_buff *);
  
 -      void (*send)(struct vport *, struct sk_buff *);
 +      netdev_tx_t (*send) (struct sk_buff *skb);
-       int (*get_egress_tun_info)(struct vport *, struct sk_buff *,
-                                  struct dp_upcall_info *upcall);
- 
        struct module *owner;
        struct list_head list;
  };