Lines Matching +full:chg +full:- +full:int

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * IPv6 over IPv4 tunnel device - Simple Internet Transition (SIT)
60 For comments look at net/ipv4/ip_gre.c --ANK
70 static int ipip6_tunnel_init(struct net_device *dev);
77 static unsigned int sit_net_id __read_mostly;
92 return net_generic(t->net, sit_net_id);
101 int sifindex)
103 unsigned int h0 = HASH(remote);
104 unsigned int h1 = HASH(local);
107 int ifindex = dev ? dev->ifindex : 0;
109 for_each_ip_tunnel_rcu(t, sitn->tunnels_r_l[h0 ^ h1]) {
110 if (local == t->parms.iph.saddr &&
111 remote == t->parms.iph.daddr &&
112 (!dev || !t->parms.link || ifindex == t->parms.link ||
113 sifindex == t->parms.link) &&
114 (t->dev->flags & IFF_UP))
117 for_each_ip_tunnel_rcu(t, sitn->tunnels_r[h0]) {
118 if (remote == t->parms.iph.daddr &&
119 (!dev || !t->parms.link || ifindex == t->parms.link ||
120 sifindex == t->parms.link) &&
121 (t->dev->flags & IFF_UP))
124 for_each_ip_tunnel_rcu(t, sitn->tunnels_l[h1]) {
125 if (local == t->parms.iph.saddr &&
126 (!dev || !t->parms.link || ifindex == t->parms.link ||
127 sifindex == t->parms.link) &&
128 (t->dev->flags & IFF_UP))
131 t = rcu_dereference(sitn->tunnels_wc[0]);
132 if (t && (t->dev->flags & IFF_UP))
140 __be32 remote = parms->iph.daddr;
141 __be32 local = parms->iph.saddr;
142 unsigned int h = 0;
143 int prio = 0;
153 return &sitn->tunnels[prio][h];
159 return __ipip6_bucket(sitn, &t->parms);
169 tp = &iter->next) {
171 rcu_assign_pointer(*tp, t->next);
181 rcu_assign_pointer(t->next, rtnl_dereference(*tp));
190 if (dev == sitn->fb_tunnel_dev || !sitn->fb_tunnel_dev) {
191 ipv6_addr_set(&t->ip6rd.prefix, htonl(0x20020000), 0, 0, 0);
192 t->ip6rd.relay_prefix = 0;
193 t->ip6rd.prefixlen = 16;
194 t->ip6rd.relay_prefixlen = 0;
196 struct ip_tunnel *t0 = netdev_priv(sitn->fb_tunnel_dev);
197 memcpy(&t->ip6rd, &t0->ip6rd, sizeof(t->ip6rd));
202 static int ipip6_tunnel_create(struct net_device *dev)
205 struct sit_net *sitn = net_generic(t->net, sit_net_id);
206 int err;
208 __dev_addr_set(dev, &t->parms.iph.saddr, 4);
209 memcpy(dev->broadcast, &t->parms.iph.daddr, 4);
211 if (test_bit(IP_TUNNEL_SIT_ISATAP_BIT, t->parms.i_flags))
212 dev->priv_flags |= IFF_ISATAP;
214 dev->rtnl_link_ops = &sit_link_ops;
231 int create)
233 __be32 remote = parms->iph.daddr;
234 __be32 local = parms->iph.saddr;
243 tp = &t->next) {
244 if (local == t->parms.iph.saddr &&
245 remote == t->parms.iph.daddr &&
246 parms->link == t->parms.link) {
256 if (parms->name[0]) {
257 if (!dev_valid_name(parms->name))
259 strscpy(name, parms->name, IFNAMSIZ);
272 nt->net = net;
273 nt->parms = *parms;
277 if (!parms->name[0])
278 strcpy(parms->name, dev->name);
291 prl = rcu_dereference(prl->next))
298 for_each_prl_rcu(t->prl)
299 if (prl->addr == addr)
305 static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __user *a)
310 unsigned int cmax, c = 0, ca, len;
311 int ret = 0;
313 if (dev == dev_to_sit_net(dev)->fb_tunnel_dev)
314 return -EINVAL;
317 return -EFAULT;
329 ca = min(t->prl_count, cmax);
333 * non-root users.
340 ret = -ENOMEM;
346 for_each_prl_rcu(t->prl) {
349 if (kprl.addr != htonl(INADDR_ANY) && prl->addr != kprl.addr)
351 kp[c].addr = prl->addr;
352 kp[c].flags = prl->flags;
362 if ((len && copy_to_user(a + 1, kp, len)) || put_user(len, &a->datalen))
363 ret = -EFAULT;
370 static int
371 ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg)
374 int err = 0;
376 if (a->addr == htonl(INADDR_ANY))
377 return -EINVAL;
381 for (p = rtnl_dereference(t->prl); p; p = rtnl_dereference(p->next)) {
382 if (p->addr == a->addr) {
383 if (chg) {
384 p->flags = a->flags;
387 err = -EEXIST;
392 if (chg) {
393 err = -ENXIO;
399 err = -ENOBUFS;
403 p->next = t->prl;
404 p->addr = a->addr;
405 p->flags = a->flags;
406 t->prl_count++;
407 rcu_assign_pointer(t->prl, p);
418 n = rcu_dereference_protected(p->next, 1);
424 static int
429 int err = 0;
433 if (a && a->addr != htonl(INADDR_ANY)) {
434 for (p = &t->prl;
436 p = &x->next) {
437 if (x->addr == a->addr) {
438 *p = x->next;
440 t->prl_count--;
444 err = -ENXIO;
446 x = rtnl_dereference(t->prl);
448 t->prl_count = 0;
449 call_rcu(&x->rcu_head, prl_list_destroy_rcu);
450 t->prl = NULL;
457 static int ipip6_tunnel_prl_ctl(struct net_device *dev,
458 struct ip_tunnel_prl __user *data, int cmd)
462 int err;
464 if (!ns_capable(t->net->user_ns, CAP_NET_ADMIN))
465 return -EPERM;
466 if (dev == dev_to_sit_net(dev)->fb_tunnel_dev)
467 return -EINVAL;
470 return -EFAULT;
481 dst_cache_reset(&t->dst_cache);
486 static int
490 int ok = 1;
493 p = __ipip6_tunnel_locate_prl(t, iph->saddr);
495 if (p->flags & PRL_DEFAULT)
496 skb->ndisc_nodetype = NDISC_NODETYPE_DEFAULT;
498 skb->ndisc_nodetype = NDISC_NODETYPE_NODEFAULT;
500 const struct in6_addr *addr6 = &ipv6_hdr(skb)->saddr;
503 (addr6->s6_addr32[3] == iph->saddr) &&
504 ipv6_chk_prefix(addr6, t->dev))
505 skb->ndisc_nodetype = NDISC_NODETYPE_HOST;
516 struct sit_net *sitn = net_generic(tunnel->net, sit_net_id);
518 if (dev == sitn->fb_tunnel_dev) {
519 RCU_INIT_POINTER(sitn->tunnels_wc[0], NULL);
524 dst_cache_reset(&tunnel->dst_cache);
525 netdev_put(dev, &tunnel->dev_tracker);
528 static int ipip6_err(struct sk_buff *skb, u32 info)
530 const struct iphdr *iph = (const struct iphdr *)skb->data;
531 const int type = icmp_hdr(skb)->type;
532 const int code = icmp_hdr(skb)->code;
533 unsigned int data_len = 0;
535 int sifindex;
536 int err;
551 I believe they are just ether pollution. --ANK
559 data_len = icmp_hdr(skb)->un.reserved[1] * 4; /* RFC 4884 4.1 */
565 err = -ENOENT;
567 sifindex = netif_is_l3_master(skb->dev) ? IPCB(skb)->iif : 0;
568 t = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
569 iph->daddr, iph->saddr, sifindex);
574 ipv4_update_pmtu(skb, dev_net(skb->dev), info,
575 t->parms.link, iph->protocol);
580 ipv4_redirect(skb, dev_net(skb->dev), t->parms.link,
581 iph->protocol);
587 if (__in6_dev_get(skb->dev) &&
588 !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4, type, data_len))
591 if (t->parms.iph.daddr == 0)
594 if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)
597 if (time_before(jiffies, t->err_time + IPTUNNEL_ERR_TIMEO))
598 t->err_count++;
600 t->err_count = 1;
601 t->err_time = jiffies;
630 int prefix_len;
633 prefix_len = tunnel->ip6rd.prefixlen + 32
634 - tunnel->ip6rd.relay_prefixlen;
638 return ipv6_chk_custom_prefix(v6dst, prefix_len, tunnel->dev);
648 if (tunnel->dev->priv_flags & IFF_ISATAP) {
655 if (tunnel->dev->flags & IFF_POINTOPOINT)
660 if (unlikely(is_spoofed_6rd(tunnel, iph->saddr, &ipv6h->saddr))) {
661 net_warn_ratelimited("Src spoofed %pI4/%pI6c -> %pI4/%pI6c\n",
662 &iph->saddr, &ipv6h->saddr,
663 &iph->daddr, &ipv6h->daddr);
667 if (likely(!is_spoofed_6rd(tunnel, iph->daddr, &ipv6h->daddr)))
670 if (only_dnatted(tunnel, &ipv6h->daddr))
673 net_warn_ratelimited("Dst spoofed %pI4/%pI6c -> %pI4/%pI6c\n",
674 &iph->saddr, &ipv6h->saddr,
675 &iph->daddr, &ipv6h->daddr);
679 static int ipip6_rcv(struct sk_buff *skb)
683 int sifindex;
684 int err;
686 sifindex = netif_is_l3_master(skb->dev) ? IPCB(skb)->iif : 0;
687 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
688 iph->saddr, iph->daddr, sifindex);
690 if (tunnel->parms.iph.protocol != IPPROTO_IPV6 &&
691 tunnel->parms.iph.protocol != 0)
694 skb->mac_header = skb->network_header;
696 IPCB(skb)->flags = 0;
697 skb->dev = tunnel->dev;
700 DEV_STATS_INC(tunnel->dev, rx_errors);
705 !net_eq(tunnel->net, dev_net(tunnel->dev))))
717 net_info_ratelimited("non-ECT from %pI4 with TOS=%#x\n",
718 &iph->saddr, iph->tos);
720 DEV_STATS_INC(tunnel->dev, rx_frame_errors);
721 DEV_STATS_INC(tunnel->dev, rx_errors);
726 dev_sw_netstats_rx_add(tunnel->dev, skb->len);
752 static int sit_tunnel_rcv(struct sk_buff *skb, u8 ipproto)
756 int sifindex;
758 sifindex = netif_is_l3_master(skb->dev) ? IPCB(skb)->iif : 0;
761 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
762 iph->saddr, iph->daddr, sifindex);
766 if (tunnel->parms.iph.protocol != ipproto &&
767 tunnel->parms.iph.protocol != 0)
778 if (iptunnel_pull_header(skb, 0, tpi->proto, false))
792 static int ipip_rcv(struct sk_buff *skb)
798 static int mplsip_rcv(struct sk_buff *skb)
812 if (ipv6_prefix_equal(v6dst, &tunnel->ip6rd.prefix,
813 tunnel->ip6rd.prefixlen)) {
814 unsigned int pbw0, pbi0;
815 int pbi1;
818 pbw0 = tunnel->ip6rd.prefixlen >> 5;
819 pbi0 = tunnel->ip6rd.prefixlen & 0x1f;
821 d = tunnel->ip6rd.relay_prefixlen < 32 ?
822 (ntohl(v6dst->s6_addr32[pbw0]) << pbi0) >>
823 tunnel->ip6rd.relay_prefixlen : 0;
825 pbi1 = pbi0 - tunnel->ip6rd.relay_prefixlen;
827 d |= ntohl(v6dst->s6_addr32[pbw0 + 1]) >>
828 (32 - pbi1);
830 *v4dst = tunnel->ip6rd.relay_prefix | htonl(d);
834 if (v6dst->s6_addr16[0] == htons(0x2002)) {
836 memcpy(v4dst, &v6dst->s6_addr16[1], 4);
858 int addr_type;
861 neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr);
868 addr6 = (const struct in6_addr *)&neigh->primary_key;
874 *dst = addr6->s6_addr32[3];
879 addr6 = &ipv6_hdr(skb)->daddr;
884 *dst = addr6->s6_addr32[3];
903 const struct iphdr *tiph = &tunnel->parms.iph;
905 u8 tos = tunnel->parms.iph.tos;
906 __be16 df = tiph->frag_off;
909 unsigned int max_headroom; /* The extra header space needed */
910 __be32 dst = tiph->daddr;
912 int mtu;
915 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
920 /* ISATAP (RFC4214) - must come before 6to4 */
921 if ((dev->priv_flags & IFF_ISATAP) &&
926 dst = try_6rd(tunnel, &iph6->daddr);
931 flowi4_init_output(&fl4, tunnel->parms.link, tunnel->fwmark,
933 IPPROTO_IPV6, 0, dst, tiph->saddr, 0, 0,
934 sock_net_uid(tunnel->net, NULL));
936 rt = dst_cache_get_ip4(&tunnel->dst_cache, &fl4.saddr);
938 rt = ip_route_output_flow(tunnel->net, &fl4, NULL);
943 dst_cache_set_ip4(&tunnel->dst_cache, &rt->dst, fl4.saddr);
946 if (rt->rt_type != RTN_UNICAST && rt->rt_type != RTN_LOCAL) {
951 tdev = rt->dst.dev;
965 mtu = dst_mtu(&rt->dst) - t_hlen;
978 if (tunnel->parms.iph.daddr)
981 if (skb->len > mtu && !skb_is_gso(skb)) {
988 if (tunnel->err_count > 0) {
990 tunnel->err_time + IPTUNNEL_ERR_TIMEO)) {
991 tunnel->err_count--;
994 tunnel->err_count = 0;
998 * Okay, now see if we can stuff it in the buffer as-is.
1011 if (skb->sk)
1012 skb_set_owner_w(new_skb, skb->sk);
1017 ttl = tiph->ttl;
1019 ttl = iph6->hop_limit;
1022 if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0) {
1030 df, !net_eq(tunnel->net, dev_net(dev)), 0);
1045 const struct iphdr *tiph = &tunnel->parms.iph;
1066 switch (skb->protocol) {
1094 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
1096 int hlen = LL_MAX_HEADER;
1100 iph = &tunnel->parms.iph;
1102 if (iph->daddr) {
1103 struct rtable *rt = ip_route_output_ports(tunnel->net, &fl4,
1105 iph->daddr, iph->saddr,
1108 iph->tos & INET_DSCP_MASK,
1109 tunnel->parms.link);
1112 tdev = rt->dst.dev;
1115 dev->flags |= IFF_POINTOPOINT;
1118 if (!tdev && tunnel->parms.link)
1119 tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link);
1122 int mtu;
1124 mtu = tdev->mtu - t_hlen;
1127 WRITE_ONCE(dev->mtu, mtu);
1128 hlen = tdev->hard_header_len + tdev->needed_headroom;
1130 dev->needed_headroom = t_hlen + hlen;
1137 struct net *net = t->net;
1142 t->parms.iph.saddr = p->iph.saddr;
1143 t->parms.iph.daddr = p->iph.daddr;
1144 __dev_addr_set(t->dev, &p->iph.saddr, 4);
1145 memcpy(t->dev->broadcast, &p->iph.daddr, 4);
1147 t->parms.iph.ttl = p->iph.ttl;
1148 t->parms.iph.tos = p->iph.tos;
1149 t->parms.iph.frag_off = p->iph.frag_off;
1150 if (t->parms.link != p->link || t->fwmark != fwmark) {
1151 t->parms.link = p->link;
1152 t->fwmark = fwmark;
1153 ipip6_tunnel_bind_dev(t->dev);
1155 dst_cache_reset(&t->dst_cache);
1156 netdev_state_change(t->dev);
1160 static int ipip6_tunnel_update_6rd(struct ip_tunnel *t,
1166 if (ip6rd->relay_prefixlen > 32 ||
1167 ip6rd->prefixlen + (32 - ip6rd->relay_prefixlen) > 64)
1168 return -EINVAL;
1170 ipv6_addr_prefix(&prefix, &ip6rd->prefix, ip6rd->prefixlen);
1171 if (!ipv6_addr_equal(&prefix, &ip6rd->prefix))
1172 return -EINVAL;
1173 if (ip6rd->relay_prefixlen)
1174 relay_prefix = ip6rd->relay_prefix &
1176 (32 - ip6rd->relay_prefixlen));
1179 if (relay_prefix != ip6rd->relay_prefix)
1180 return -EINVAL;
1182 t->ip6rd.prefix = prefix;
1183 t->ip6rd.relay_prefix = relay_prefix;
1184 t->ip6rd.prefixlen = ip6rd->prefixlen;
1185 t->ip6rd.relay_prefixlen = ip6rd->relay_prefixlen;
1186 dst_cache_reset(&t->dst_cache);
1187 netdev_state_change(t->dev);
1191 static int
1198 if (dev == dev_to_sit_net(dev)->fb_tunnel_dev) {
1200 return -EFAULT;
1201 t = ipip6_tunnel_locate(t->net, &p, 0);
1206 ip6rd.prefix = t->ip6rd.prefix;
1207 ip6rd.relay_prefix = t->ip6rd.relay_prefix;
1208 ip6rd.prefixlen = t->ip6rd.prefixlen;
1209 ip6rd.relay_prefixlen = t->ip6rd.relay_prefixlen;
1211 return -EFAULT;
1215 static int
1217 int cmd)
1221 int err;
1223 if (!ns_capable(t->net->user_ns, CAP_NET_ADMIN))
1224 return -EPERM;
1226 return -EFAULT;
1249 static int
1252 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
1253 return -EPERM;
1255 if (!ipip6_valid_ip_proto(p->iph.protocol))
1256 return -EINVAL;
1257 if (p->iph.version != 4 ||
1258 p->iph.ihl != 5 || (p->iph.frag_off & htons(~IP_DF)))
1259 return -EINVAL;
1261 if (p->iph.ttl)
1262 p->iph.frag_off |= htons(IP_DF);
1266 static int
1271 if (dev == dev_to_sit_net(dev)->fb_tunnel_dev)
1272 t = ipip6_tunnel_locate(t->net, p, 0);
1275 memcpy(p, &t->parms, sizeof(*p));
1279 static int
1283 int err;
1285 err = __ipip6_tunnel_ioctl_validate(t->net, p);
1289 t = ipip6_tunnel_locate(t->net, p, 1);
1291 return -ENOBUFS;
1295 static int
1299 int err;
1301 err = __ipip6_tunnel_ioctl_validate(t->net, p);
1305 t = ipip6_tunnel_locate(t->net, p, 0);
1306 if (dev == dev_to_sit_net(dev)->fb_tunnel_dev) {
1308 return -ENOENT;
1311 if (t->dev != dev)
1312 return -EEXIST;
1314 if (((dev->flags & IFF_POINTOPOINT) && !p->iph.daddr) ||
1315 (!(dev->flags & IFF_POINTOPOINT) && p->iph.daddr))
1316 return -EINVAL;
1320 ipip6_tunnel_update(t, p, t->fwmark);
1326 static int
1331 if (!ns_capable(t->net->user_ns, CAP_NET_ADMIN))
1332 return -EPERM;
1334 if (dev == dev_to_sit_net(dev)->fb_tunnel_dev) {
1335 t = ipip6_tunnel_locate(t->net, p, 0);
1337 return -ENOENT;
1338 if (t == netdev_priv(dev_to_sit_net(dev)->fb_tunnel_dev))
1339 return -EPERM;
1340 dev = t->dev;
1346 static int
1348 int cmd)
1360 return -EINVAL;
1364 static int
1366 void __user *data, int cmd)
1389 return -EINVAL;
1406 dst_cache_destroy(&tunnel->dst_cache);
1418 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
1420 dev->netdev_ops = &ipip6_netdev_ops;
1421 dev->header_ops = &ip_tunnel_header_ops;
1422 dev->needs_free_netdev = true;
1423 dev->priv_destructor = ipip6_dev_free;
1425 dev->type = ARPHRD_SIT;
1426 dev->mtu = ETH_DATA_LEN - t_hlen;
1427 dev->min_mtu = IPV6_MIN_MTU;
1428 dev->max_mtu = IP6_MAX_MTU - t_hlen;
1429 dev->flags = IFF_NOARP;
1431 dev->addr_len = 4;
1432 dev->lltx = true;
1433 dev->features |= SIT_FEATURES;
1434 dev->hw_features |= SIT_FEATURES;
1435 dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
1439 static int ipip6_tunnel_init(struct net_device *dev)
1442 int err;
1444 tunnel->dev = dev;
1445 strcpy(tunnel->parms.name, dev->name);
1449 err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL);
1453 netdev_hold(dev, &tunnel->dev_tracker, GFP_KERNEL);
1461 struct iphdr *iph = &tunnel->parms.iph;
1465 iph->version = 4;
1466 iph->protocol = IPPROTO_IPV6;
1467 iph->ihl = 5;
1468 iph->ttl = 64;
1470 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
1473 static int ipip6_validate(struct nlattr *tb[], struct nlattr *data[],
1483 return -EINVAL;
1494 parms->iph.version = 4;
1495 parms->iph.protocol = IPPROTO_IPV6;
1496 parms->iph.ihl = 5;
1497 parms->iph.ttl = 64;
1521 ip6rd->prefix = nla_get_in6_addr(data[IFLA_IPTUN_6RD_PREFIX]);
1526 ip6rd->relay_prefix =
1532 ip6rd->prefixlen = nla_get_u16(data[IFLA_IPTUN_6RD_PREFIXLEN]);
1537 ip6rd->relay_prefixlen =
1545 static int ipip6_newlink(struct net_device *dev,
1549 struct nlattr **data = params->data;
1550 struct nlattr **tb = params->tb;
1557 int err;
1559 net = params->link_net ? : dev_net(dev);
1561 nt->net = net;
1569 ipip6_netlink_parms(data, &nt->parms, &nt->fwmark);
1571 if (ipip6_tunnel_locate(net, &nt->parms, 0))
1572 return -EEXIST;
1582 mtu <= IP6_MAX_MTU - dev->hard_header_len)
1583 dev->mtu = mtu;
1597 static int ipip6_changelink(struct net_device *dev, struct nlattr *tb[],
1604 struct net *net = t->net;
1609 __u32 fwmark = t->fwmark;
1610 int err;
1612 if (dev == sitn->fb_tunnel_dev)
1613 return -EINVAL;
1623 if (((dev->flags & IFF_POINTOPOINT) && !p.iph.daddr) ||
1624 (!(dev->flags & IFF_POINTOPOINT) && p.iph.daddr))
1625 return -EINVAL;
1630 if (t->dev != dev)
1631 return -EEXIST;
1687 static int ipip6_fill_info(struct sk_buff *skb, const struct net_device *dev)
1690 struct ip_tunnel_parm_kern *parm = &tunnel->parms;
1692 if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) ||
1693 nla_put_in_addr(skb, IFLA_IPTUN_LOCAL, parm->iph.saddr) ||
1694 nla_put_in_addr(skb, IFLA_IPTUN_REMOTE, parm->iph.daddr) ||
1695 nla_put_u8(skb, IFLA_IPTUN_TTL, parm->iph.ttl) ||
1696 nla_put_u8(skb, IFLA_IPTUN_TOS, parm->iph.tos) ||
1698 !!(parm->iph.frag_off & htons(IP_DF))) ||
1699 nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->iph.protocol) ||
1701 ip_tunnel_flags_to_be16(parm->i_flags)) ||
1702 nla_put_u32(skb, IFLA_IPTUN_FWMARK, tunnel->fwmark))
1707 &tunnel->ip6rd.prefix) ||
1709 tunnel->ip6rd.relay_prefix) ||
1711 tunnel->ip6rd.prefixlen) ||
1713 tunnel->ip6rd.relay_prefixlen))
1718 tunnel->encap.type) ||
1720 tunnel->encap.sport) ||
1722 tunnel->encap.dport) ||
1724 tunnel->encap.flags))
1730 return -EMSGSIZE;
1760 if (dev != sitn->fb_tunnel_dev)
1803 int prio;
1806 if (dev->rtnl_link_ops == &sit_link_ops)
1810 int h;
1814 t = rtnl_net_dereference(net, sitn->tunnels[prio][h]);
1819 if (!net_eq(dev_net(t->dev), net))
1820 unregister_netdevice_queue(t->dev, head);
1822 t = rtnl_net_dereference(net, t->next);
1828 static int __net_init sit_init_net(struct net *net)
1832 int err;
1834 sitn->tunnels[0] = sitn->tunnels_wc;
1835 sitn->tunnels[1] = sitn->tunnels_l;
1836 sitn->tunnels[2] = sitn->tunnels_r;
1837 sitn->tunnels[3] = sitn->tunnels_r_l;
1842 sitn->fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0",
1845 if (!sitn->fb_tunnel_dev) {
1846 err = -ENOMEM;
1849 dev_net_set(sitn->fb_tunnel_dev, net);
1850 sitn->fb_tunnel_dev->rtnl_link_ops = &sit_link_ops;
1854 sitn->fb_tunnel_dev->netns_immutable = true;
1856 t = netdev_priv(sitn->fb_tunnel_dev);
1857 t->net = net;
1859 err = register_netdev(sitn->fb_tunnel_dev);
1863 ipip6_tunnel_clone_6rd(sitn->fb_tunnel_dev, sitn);
1864 ipip6_fb_tunnel_init(sitn->fb_tunnel_dev);
1866 strcpy(t->parms.name, sitn->fb_tunnel_dev->name);
1870 free_netdev(sitn->fb_tunnel_dev);
1895 static int __init sit_init(void)
1897 int err;
1943 MODULE_DESCRIPTION("IPv6-in-IPv4 tunnel SIT driver");