hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/net/mpls/mpls_iptunnel.c
....@@ -1,14 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * mpls tunnels An implementation mpls tunnels using the light weight tunnel
34 * infrastructure
45 *
56 * 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
- *
127 */
138 #include <linux/types.h>
149 #include <linux/skbuff.h>
....@@ -137,12 +132,22 @@
137132
138133 mpls_stats_inc_outucastpkts(out_dev, skb);
139134
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
+ }
146151 if (err)
147152 net_dbg_ratelimited("%s: packet transmission failed: %d\n",
148153 __func__, err);
....@@ -157,7 +162,7 @@
157162 return -EINVAL;
158163 }
159164
160
-static int mpls_build_state(struct nlattr *nla,
165
+static int mpls_build_state(struct net *net, struct nlattr *nla,
161166 unsigned int family, const void *cfg,
162167 struct lwtunnel_state **ts,
163168 struct netlink_ext_ack *extack)
....@@ -168,8 +173,8 @@
168173 u8 n_labels;
169174 int ret;
170175
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);
173178 if (ret < 0)
174179 return ret;
175180
....@@ -183,8 +188,8 @@
183188 &n_labels, NULL, extack))
184189 return -EINVAL;
185190
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));
188193 if (!newts)
189194 return -ENOMEM;
190195
....@@ -295,5 +300,6 @@
295300 module_exit(mpls_iptunnel_exit);
296301
297302 MODULE_ALIAS_RTNL_LWT(MPLS);
303
+MODULE_SOFTDEP("post: mpls_gso");
298304 MODULE_DESCRIPTION("MultiProtocol Label Switching IP Tunnels");
299305 MODULE_LICENSE("GPL v2");