| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * mpls tunnels An implementation mpls tunnels using the light weight tunnel |
|---|
| 3 | 4 | * infrastructure |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * Authors: Roopa Prabhu, <roopa@cumulusnetworks.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or |
|---|
| 8 | | - * modify it under the terms of the GNU General Public License |
|---|
| 9 | | - * as published by the Free Software Foundation; either version |
|---|
| 10 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 11 | | - * |
|---|
| 12 | 7 | */ |
|---|
| 13 | 8 | #include <linux/types.h> |
|---|
| 14 | 9 | #include <linux/skbuff.h> |
|---|
| .. | .. |
|---|
| 137 | 132 | |
|---|
| 138 | 133 | mpls_stats_inc_outucastpkts(out_dev, skb); |
|---|
| 139 | 134 | |
|---|
| 140 | | - if (rt) |
|---|
| 141 | | - err = neigh_xmit(NEIGH_ARP_TABLE, out_dev, &rt->rt_gateway, |
|---|
| 142 | | - skb); |
|---|
| 143 | | - else if (rt6) |
|---|
| 144 | | - err = neigh_xmit(NEIGH_ND_TABLE, out_dev, &rt6->rt6i_gateway, |
|---|
| 145 | | - skb); |
|---|
| 135 | + if (rt) { |
|---|
| 136 | + if (rt->rt_gw_family == AF_INET6) |
|---|
| 137 | + err = neigh_xmit(NEIGH_ND_TABLE, out_dev, &rt->rt_gw6, |
|---|
| 138 | + skb); |
|---|
| 139 | + else |
|---|
| 140 | + err = neigh_xmit(NEIGH_ARP_TABLE, out_dev, &rt->rt_gw4, |
|---|
| 141 | + skb); |
|---|
| 142 | + } else if (rt6) { |
|---|
| 143 | + if (ipv6_addr_v4mapped(&rt6->rt6i_gateway)) { |
|---|
| 144 | + /* 6PE (RFC 4798) */ |
|---|
| 145 | + err = neigh_xmit(NEIGH_ARP_TABLE, out_dev, &rt6->rt6i_gateway.s6_addr32[3], |
|---|
| 146 | + skb); |
|---|
| 147 | + } else |
|---|
| 148 | + err = neigh_xmit(NEIGH_ND_TABLE, out_dev, &rt6->rt6i_gateway, |
|---|
| 149 | + skb); |
|---|
| 150 | + } |
|---|
| 146 | 151 | if (err) |
|---|
| 147 | 152 | net_dbg_ratelimited("%s: packet transmission failed: %d\n", |
|---|
| 148 | 153 | __func__, err); |
|---|
| .. | .. |
|---|
| 157 | 162 | return -EINVAL; |
|---|
| 158 | 163 | } |
|---|
| 159 | 164 | |
|---|
| 160 | | -static int mpls_build_state(struct nlattr *nla, |
|---|
| 165 | +static int mpls_build_state(struct net *net, struct nlattr *nla, |
|---|
| 161 | 166 | unsigned int family, const void *cfg, |
|---|
| 162 | 167 | struct lwtunnel_state **ts, |
|---|
| 163 | 168 | struct netlink_ext_ack *extack) |
|---|
| .. | .. |
|---|
| 168 | 173 | u8 n_labels; |
|---|
| 169 | 174 | int ret; |
|---|
| 170 | 175 | |
|---|
| 171 | | - ret = nla_parse_nested(tb, MPLS_IPTUNNEL_MAX, nla, |
|---|
| 172 | | - mpls_iptunnel_policy, extack); |
|---|
| 176 | + ret = nla_parse_nested_deprecated(tb, MPLS_IPTUNNEL_MAX, nla, |
|---|
| 177 | + mpls_iptunnel_policy, extack); |
|---|
| 173 | 178 | if (ret < 0) |
|---|
| 174 | 179 | return ret; |
|---|
| 175 | 180 | |
|---|
| .. | .. |
|---|
| 183 | 188 | &n_labels, NULL, extack)) |
|---|
| 184 | 189 | return -EINVAL; |
|---|
| 185 | 190 | |
|---|
| 186 | | - newts = lwtunnel_state_alloc(sizeof(*tun_encap_info) + |
|---|
| 187 | | - n_labels * sizeof(u32)); |
|---|
| 191 | + newts = lwtunnel_state_alloc(struct_size(tun_encap_info, label, |
|---|
| 192 | + n_labels)); |
|---|
| 188 | 193 | if (!newts) |
|---|
| 189 | 194 | return -ENOMEM; |
|---|
| 190 | 195 | |
|---|
| .. | .. |
|---|
| 295 | 300 | module_exit(mpls_iptunnel_exit); |
|---|
| 296 | 301 | |
|---|
| 297 | 302 | MODULE_ALIAS_RTNL_LWT(MPLS); |
|---|
| 303 | +MODULE_SOFTDEP("post: mpls_gso"); |
|---|
| 298 | 304 | MODULE_DESCRIPTION("MultiProtocol Label Switching IP Tunnels"); |
|---|
| 299 | 305 | MODULE_LICENSE("GPL v2"); |
|---|