diff options
author | David S. Miller <davem@davemloft.net> | 2016-09-04 14:42:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-09-04 14:42:57 -0400 |
commit | 2f83a53a81f5695b0f13635d411cd78367e547d6 (patch) | |
tree | 49b85f27db9f38296be58675bcd84e623894276b | |
parent | 24b27fc4cdf9e10c5e79e5923b6b7c2c5c95096c (diff) | |
parent | 3555621de7fcceb79c4850f3d07d1ae4f652acf6 (diff) |
Merge branch 'vxlan-fixes'
Jiri Benc says:
====================
vxlan: fix error reporting
This patchset improves checking for invalid configuration in VXLAN and
fixes problems with duplicated and inappropriate error messages.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/vxlan.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index c0dda6fc0921..6e65832051d6 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -2782,14 +2782,15 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, | |||
2782 | struct net_device *lowerdev = NULL; | 2782 | struct net_device *lowerdev = NULL; |
2783 | 2783 | ||
2784 | if (conf->flags & VXLAN_F_GPE) { | 2784 | if (conf->flags & VXLAN_F_GPE) { |
2785 | if (conf->flags & ~VXLAN_F_ALLOWED_GPE) | ||
2786 | return -EINVAL; | ||
2787 | /* For now, allow GPE only together with COLLECT_METADATA. | 2785 | /* For now, allow GPE only together with COLLECT_METADATA. |
2788 | * This can be relaxed later; in such case, the other side | 2786 | * This can be relaxed later; in such case, the other side |
2789 | * of the PtP link will have to be provided. | 2787 | * of the PtP link will have to be provided. |
2790 | */ | 2788 | */ |
2791 | if (!(conf->flags & VXLAN_F_COLLECT_METADATA)) | 2789 | if ((conf->flags & ~VXLAN_F_ALLOWED_GPE) || |
2790 | !(conf->flags & VXLAN_F_COLLECT_METADATA)) { | ||
2791 | pr_info("unsupported combination of extensions\n"); | ||
2792 | return -EINVAL; | 2792 | return -EINVAL; |
2793 | } | ||
2793 | 2794 | ||
2794 | vxlan_raw_setup(dev); | 2795 | vxlan_raw_setup(dev); |
2795 | } else { | 2796 | } else { |
@@ -2842,6 +2843,9 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, | |||
2842 | dev->mtu = lowerdev->mtu - (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM); | 2843 | dev->mtu = lowerdev->mtu - (use_ipv6 ? VXLAN6_HEADROOM : VXLAN_HEADROOM); |
2843 | 2844 | ||
2844 | needed_headroom = lowerdev->hard_header_len; | 2845 | needed_headroom = lowerdev->hard_header_len; |
2846 | } else if (vxlan_addr_multicast(&dst->remote_ip)) { | ||
2847 | pr_info("multicast destination requires interface to be specified\n"); | ||
2848 | return -EINVAL; | ||
2845 | } | 2849 | } |
2846 | 2850 | ||
2847 | if (conf->mtu) { | 2851 | if (conf->mtu) { |
@@ -2874,8 +2878,10 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, | |||
2874 | tmp->cfg.saddr.sa.sa_family == AF_INET6) == use_ipv6 && | 2878 | tmp->cfg.saddr.sa.sa_family == AF_INET6) == use_ipv6 && |
2875 | tmp->cfg.dst_port == vxlan->cfg.dst_port && | 2879 | tmp->cfg.dst_port == vxlan->cfg.dst_port && |
2876 | (tmp->flags & VXLAN_F_RCV_FLAGS) == | 2880 | (tmp->flags & VXLAN_F_RCV_FLAGS) == |
2877 | (vxlan->flags & VXLAN_F_RCV_FLAGS)) | 2881 | (vxlan->flags & VXLAN_F_RCV_FLAGS)) { |
2878 | return -EEXIST; | 2882 | pr_info("duplicate VNI %u\n", be32_to_cpu(conf->vni)); |
2883 | return -EEXIST; | ||
2884 | } | ||
2879 | } | 2885 | } |
2880 | 2886 | ||
2881 | dev->ethtool_ops = &vxlan_ethtool_ops; | 2887 | dev->ethtool_ops = &vxlan_ethtool_ops; |
@@ -2909,7 +2915,6 @@ static int vxlan_newlink(struct net *src_net, struct net_device *dev, | |||
2909 | struct nlattr *tb[], struct nlattr *data[]) | 2915 | struct nlattr *tb[], struct nlattr *data[]) |
2910 | { | 2916 | { |
2911 | struct vxlan_config conf; | 2917 | struct vxlan_config conf; |
2912 | int err; | ||
2913 | 2918 | ||
2914 | memset(&conf, 0, sizeof(conf)); | 2919 | memset(&conf, 0, sizeof(conf)); |
2915 | 2920 | ||
@@ -3018,26 +3023,7 @@ static int vxlan_newlink(struct net *src_net, struct net_device *dev, | |||
3018 | if (tb[IFLA_MTU]) | 3023 | if (tb[IFLA_MTU]) |
3019 | conf.mtu = nla_get_u32(tb[IFLA_MTU]); | 3024 | conf.mtu = nla_get_u32(tb[IFLA_MTU]); |
3020 | 3025 | ||
3021 | err = vxlan_dev_configure(src_net, dev, &conf); | 3026 | return vxlan_dev_configure(src_net, dev, &conf); |
3022 | switch (err) { | ||
3023 | case -ENODEV: | ||
3024 | pr_info("ifindex %d does not exist\n", conf.remote_ifindex); | ||
3025 | break; | ||
3026 | |||
3027 | case -EPERM: | ||
3028 | pr_info("IPv6 is disabled via sysctl\n"); | ||
3029 | break; | ||
3030 | |||
3031 | case -EEXIST: | ||
3032 | pr_info("duplicate VNI %u\n", be32_to_cpu(conf.vni)); | ||
3033 | break; | ||
3034 | |||
3035 | case -EINVAL: | ||
3036 | pr_info("unsupported combination of extensions\n"); | ||
3037 | break; | ||
3038 | } | ||
3039 | |||
3040 | return err; | ||
3041 | } | 3027 | } |
3042 | 3028 | ||
3043 | static void vxlan_dellink(struct net_device *dev, struct list_head *head) | 3029 | static void vxlan_dellink(struct net_device *dev, struct list_head *head) |