similarity index 98%rename from kernel/drivers/net/vxlan.crename to kernel/drivers/net/vxlan/vxlan_core.c.. | .. |
---|
729 | 729 | return 1; |
---|
730 | 730 | } |
---|
731 | 731 | |
---|
| 732 | +static bool vxlan_parse_gpe_proto(struct vxlanhdr *hdr, __be16 *protocol) |
---|
| 733 | +{ |
---|
| 734 | + struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)hdr; |
---|
| 735 | + |
---|
| 736 | + /* Need to have Next Protocol set for interfaces in GPE mode. */ |
---|
| 737 | + if (!gpe->np_applied) |
---|
| 738 | + return false; |
---|
| 739 | + /* "The initial version is 0. If a receiver does not support the |
---|
| 740 | + * version indicated it MUST drop the packet. |
---|
| 741 | + */ |
---|
| 742 | + if (gpe->version != 0) |
---|
| 743 | + return false; |
---|
| 744 | + /* "When the O bit is set to 1, the packet is an OAM packet and OAM |
---|
| 745 | + * processing MUST occur." However, we don't implement OAM |
---|
| 746 | + * processing, thus drop the packet. |
---|
| 747 | + */ |
---|
| 748 | + if (gpe->oam_flag) |
---|
| 749 | + return false; |
---|
| 750 | + |
---|
| 751 | + *protocol = tun_p_to_eth_p(gpe->next_protocol); |
---|
| 752 | + if (!*protocol) |
---|
| 753 | + return false; |
---|
| 754 | + |
---|
| 755 | + return true; |
---|
| 756 | +} |
---|
| 757 | + |
---|
732 | 758 | static struct vxlanhdr *vxlan_gro_remcsum(struct sk_buff *skb, |
---|
733 | 759 | unsigned int off, |
---|
734 | 760 | struct vxlanhdr *vh, size_t hdrlen, |
---|
.. | .. |
---|
1737 | 1763 | unparsed->vx_flags &= ~VXLAN_GBP_USED_BITS; |
---|
1738 | 1764 | } |
---|
1739 | 1765 | |
---|
1740 | | -static bool vxlan_parse_gpe_hdr(struct vxlanhdr *unparsed, |
---|
1741 | | - __be16 *protocol, |
---|
1742 | | - struct sk_buff *skb, u32 vxflags) |
---|
1743 | | -{ |
---|
1744 | | - struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)unparsed; |
---|
1745 | | - |
---|
1746 | | - /* Need to have Next Protocol set for interfaces in GPE mode. */ |
---|
1747 | | - if (!gpe->np_applied) |
---|
1748 | | - return false; |
---|
1749 | | - /* "The initial version is 0. If a receiver does not support the |
---|
1750 | | - * version indicated it MUST drop the packet. |
---|
1751 | | - */ |
---|
1752 | | - if (gpe->version != 0) |
---|
1753 | | - return false; |
---|
1754 | | - /* "When the O bit is set to 1, the packet is an OAM packet and OAM |
---|
1755 | | - * processing MUST occur." However, we don't implement OAM |
---|
1756 | | - * processing, thus drop the packet. |
---|
1757 | | - */ |
---|
1758 | | - if (gpe->oam_flag) |
---|
1759 | | - return false; |
---|
1760 | | - |
---|
1761 | | - *protocol = tun_p_to_eth_p(gpe->next_protocol); |
---|
1762 | | - if (!*protocol) |
---|
1763 | | - return false; |
---|
1764 | | - |
---|
1765 | | - unparsed->vx_flags &= ~VXLAN_GPE_USED_BITS; |
---|
1766 | | - return true; |
---|
1767 | | -} |
---|
1768 | | - |
---|
1769 | 1766 | static bool vxlan_set_mac(struct vxlan_dev *vxlan, |
---|
1770 | 1767 | struct vxlan_sock *vs, |
---|
1771 | 1768 | struct sk_buff *skb, __be32 vni) |
---|
.. | .. |
---|
1866 | 1863 | * used by VXLAN extensions if explicitly requested. |
---|
1867 | 1864 | */ |
---|
1868 | 1865 | if (vs->flags & VXLAN_F_GPE) { |
---|
1869 | | - if (!vxlan_parse_gpe_hdr(&unparsed, &protocol, skb, vs->flags)) |
---|
| 1866 | + if (!vxlan_parse_gpe_proto(&unparsed, &protocol)) |
---|
1870 | 1867 | goto drop; |
---|
| 1868 | + unparsed.vx_flags &= ~VXLAN_GPE_USED_BITS; |
---|
1871 | 1869 | raw_proto = true; |
---|
1872 | 1870 | } |
---|
1873 | 1871 | |
---|
.. | .. |
---|
2720 | 2718 | } |
---|
2721 | 2719 | |
---|
2722 | 2720 | ndst = &rt->dst; |
---|
2723 | | - err = skb_tunnel_check_pmtu(skb, ndst, VXLAN_HEADROOM, |
---|
| 2721 | + err = skb_tunnel_check_pmtu(skb, ndst, vxlan_headroom(flags & VXLAN_F_GPE), |
---|
2724 | 2722 | netif_is_any_bridge_port(dev)); |
---|
2725 | 2723 | if (err < 0) { |
---|
2726 | 2724 | goto tx_error; |
---|
.. | .. |
---|
2781 | 2779 | goto out_unlock; |
---|
2782 | 2780 | } |
---|
2783 | 2781 | |
---|
2784 | | - err = skb_tunnel_check_pmtu(skb, ndst, VXLAN6_HEADROOM, |
---|
| 2782 | + err = skb_tunnel_check_pmtu(skb, ndst, |
---|
| 2783 | + vxlan_headroom((flags & VXLAN_F_GPE) | VXLAN_F_IPV6), |
---|
2785 | 2784 | netif_is_any_bridge_port(dev)); |
---|
2786 | 2785 | if (err < 0) { |
---|
2787 | 2786 | goto tx_error; |
---|
.. | .. |
---|
3158 | 3157 | struct vxlan_rdst *dst = &vxlan->default_dst; |
---|
3159 | 3158 | struct net_device *lowerdev = __dev_get_by_index(vxlan->net, |
---|
3160 | 3159 | dst->remote_ifindex); |
---|
3161 | | - bool use_ipv6 = !!(vxlan->cfg.flags & VXLAN_F_IPV6); |
---|
3162 | 3160 | |
---|
3163 | 3161 | /* This check is different than dev->max_mtu, because it looks at |
---|
3164 | 3162 | * the lowerdev->mtu, rather than the static dev->max_mtu |
---|
3165 | 3163 | */ |
---|
3166 | 3164 | if (lowerdev) { |
---|
3167 | | - int max_mtu = lowerdev->mtu - |
---|
3168 | | - (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM); |
---|
| 3165 | + int max_mtu = lowerdev->mtu - vxlan_headroom(vxlan->cfg.flags); |
---|
3169 | 3166 | if (new_mtu > max_mtu) |
---|
3170 | 3167 | return -EINVAL; |
---|
3171 | 3168 | } |
---|
.. | .. |
---|
3784 | 3781 | struct vxlan_dev *vxlan = netdev_priv(dev); |
---|
3785 | 3782 | struct vxlan_rdst *dst = &vxlan->default_dst; |
---|
3786 | 3783 | unsigned short needed_headroom = ETH_HLEN; |
---|
3787 | | - bool use_ipv6 = !!(conf->flags & VXLAN_F_IPV6); |
---|
3788 | 3784 | int max_mtu = ETH_MAX_MTU; |
---|
| 3785 | + u32 flags = conf->flags; |
---|
3789 | 3786 | |
---|
3790 | 3787 | if (!changelink) { |
---|
3791 | | - if (conf->flags & VXLAN_F_GPE) |
---|
| 3788 | + if (flags & VXLAN_F_GPE) |
---|
3792 | 3789 | vxlan_raw_setup(dev); |
---|
3793 | 3790 | else |
---|
3794 | 3791 | vxlan_ether_setup(dev); |
---|
.. | .. |
---|
3814 | 3811 | |
---|
3815 | 3812 | dev->needed_tailroom = lowerdev->needed_tailroom; |
---|
3816 | 3813 | |
---|
3817 | | - max_mtu = lowerdev->mtu - (use_ipv6 ? VXLAN6_HEADROOM : |
---|
3818 | | - VXLAN_HEADROOM); |
---|
| 3814 | + max_mtu = lowerdev->mtu - vxlan_headroom(flags); |
---|
3819 | 3815 | if (max_mtu < ETH_MIN_MTU) |
---|
3820 | 3816 | max_mtu = ETH_MIN_MTU; |
---|
3821 | 3817 | |
---|
.. | .. |
---|
3826 | 3822 | if (dev->mtu > max_mtu) |
---|
3827 | 3823 | dev->mtu = max_mtu; |
---|
3828 | 3824 | |
---|
3829 | | - if (use_ipv6 || conf->flags & VXLAN_F_COLLECT_METADATA) |
---|
3830 | | - needed_headroom += VXLAN6_HEADROOM; |
---|
3831 | | - else |
---|
3832 | | - needed_headroom += VXLAN_HEADROOM; |
---|
| 3825 | + if (flags & VXLAN_F_COLLECT_METADATA) |
---|
| 3826 | + flags |= VXLAN_F_IPV6; |
---|
| 3827 | + needed_headroom += vxlan_headroom(flags); |
---|
3833 | 3828 | dev->needed_headroom = needed_headroom; |
---|
3834 | 3829 | |
---|
3835 | 3830 | memcpy(&vxlan->cfg, conf, sizeof(*conf)); |
---|