ip_gre.c (654b0c9627bc1b34cc21643afa8ac359c50db7d7) ip_gre.c (f2cedb63df14342ad40a8b5b324fc5d94a60b665)
1/*
2 * Linux NET3: GRE over IP protocol decoder.
3 *
4 * Authors: Alexey Kuznetsov (kuznet@ms2.inr.ac.ru)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

--- 716 unchanged lines hidden (view full) ---

725
726 if (skb_dst(skb) == NULL) {
727 dev->stats.tx_fifo_errors++;
728 goto tx_error;
729 }
730
731 if (skb->protocol == htons(ETH_P_IP)) {
732 rt = skb_rtable(skb);
1/*
2 * Linux NET3: GRE over IP protocol decoder.
3 *
4 * Authors: Alexey Kuznetsov (kuznet@ms2.inr.ac.ru)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

--- 716 unchanged lines hidden (view full) ---

725
726 if (skb_dst(skb) == NULL) {
727 dev->stats.tx_fifo_errors++;
728 goto tx_error;
729 }
730
731 if (skb->protocol == htons(ETH_P_IP)) {
732 rt = skb_rtable(skb);
733 if ((dst = rt->rt_gateway) == 0)
734 goto tx_error_icmp;
733 dst = rt->rt_gateway;
735 }
736#if IS_ENABLED(CONFIG_IPV6)
737 else if (skb->protocol == htons(ETH_P_IPV6)) {
734 }
735#if IS_ENABLED(CONFIG_IPV6)
736 else if (skb->protocol == htons(ETH_P_IPV6)) {
738 struct neighbour *neigh = dst_get_neighbour_noref(skb_dst(skb));
739 const struct in6_addr *addr6;
737 const struct in6_addr *addr6;
738 struct neighbour *neigh;
739 bool do_tx_error_icmp;
740 int addr_type;
741
740 int addr_type;
741
742 neigh = dst_neigh_lookup(skb_dst(skb), &ipv6_hdr(skb)->daddr);
742 if (neigh == NULL)
743 goto tx_error;
744
745 addr6 = (const struct in6_addr *)&neigh->primary_key;
746 addr_type = ipv6_addr_type(addr6);
747
748 if (addr_type == IPV6_ADDR_ANY) {
749 addr6 = &ipv6_hdr(skb)->daddr;
750 addr_type = ipv6_addr_type(addr6);
751 }
752
753 if ((addr_type & IPV6_ADDR_COMPATv4) == 0)
743 if (neigh == NULL)
744 goto tx_error;
745
746 addr6 = (const struct in6_addr *)&neigh->primary_key;
747 addr_type = ipv6_addr_type(addr6);
748
749 if (addr_type == IPV6_ADDR_ANY) {
750 addr6 = &ipv6_hdr(skb)->daddr;
751 addr_type = ipv6_addr_type(addr6);
752 }
753
754 if ((addr_type & IPV6_ADDR_COMPATv4) == 0)
755 do_tx_error_icmp = true;
756 else {
757 do_tx_error_icmp = false;
758 dst = addr6->s6_addr32[3];
759 }
760 neigh_release(neigh);
761 if (do_tx_error_icmp)
754 goto tx_error_icmp;
762 goto tx_error_icmp;
755
756 dst = addr6->s6_addr32[3];
757 }
758#endif
759 else
760 goto tx_error;
761 }
762
763 tos = tiph->tos;
764 if (tos == 1) {

--- 144 unchanged lines hidden (view full) ---

909 }
910 }
911
912 nf_reset(skb);
913 tstats = this_cpu_ptr(dev->tstats);
914 __IPTUNNEL_XMIT(tstats, &dev->stats);
915 return NETDEV_TX_OK;
916
763 }
764#endif
765 else
766 goto tx_error;
767 }
768
769 tos = tiph->tos;
770 if (tos == 1) {

--- 144 unchanged lines hidden (view full) ---

915 }
916 }
917
918 nf_reset(skb);
919 tstats = this_cpu_ptr(dev->tstats);
920 __IPTUNNEL_XMIT(tstats, &dev->stats);
921 return NETDEV_TX_OK;
922
923#if IS_ENABLED(CONFIG_IPV6)
917tx_error_icmp:
918 dst_link_failure(skb);
924tx_error_icmp:
925 dst_link_failure(skb);
919
926#endif
920tx_error:
921 dev->stats.tx_errors++;
922 dev_kfree_skb(skb);
923 return NETDEV_TX_OK;
924}
925
926static int ipgre_tunnel_bind_dev(struct net_device *dev)
927{

--- 596 unchanged lines hidden (view full) ---

1524
1525 nt = netdev_priv(dev);
1526 ipgre_netlink_parms(data, &nt->parms);
1527
1528 if (ipgre_tunnel_find(net, &nt->parms, dev->type))
1529 return -EEXIST;
1530
1531 if (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS])
927tx_error:
928 dev->stats.tx_errors++;
929 dev_kfree_skb(skb);
930 return NETDEV_TX_OK;
931}
932
933static int ipgre_tunnel_bind_dev(struct net_device *dev)
934{

--- 596 unchanged lines hidden (view full) ---

1531
1532 nt = netdev_priv(dev);
1533 ipgre_netlink_parms(data, &nt->parms);
1534
1535 if (ipgre_tunnel_find(net, &nt->parms, dev->type))
1536 return -EEXIST;
1537
1538 if (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS])
1532 random_ether_addr(dev->dev_addr);
1539 eth_hw_addr_random(dev);
1533
1534 mtu = ipgre_tunnel_bind_dev(dev);
1535 if (!tb[IFLA_MTU])
1536 dev->mtu = mtu;
1537
1538 /* Can use a lockless transmit, unless we generate output sequences */
1539 if (!(nt->parms.o_flags & GRE_SEQ))
1540 dev->features |= NETIF_F_LLTX;

--- 218 unchanged lines hidden ---
1540
1541 mtu = ipgre_tunnel_bind_dev(dev);
1542 if (!tb[IFLA_MTU])
1543 dev->mtu = mtu;
1544
1545 /* Can use a lockless transmit, unless we generate output sequences */
1546 if (!(nt->parms.o_flags & GRE_SEQ))
1547 dev->features |= NETIF_F_LLTX;

--- 218 unchanged lines hidden ---