Lines Matching full:tunnel

3  *	IPv6 over IPv4 tunnel device - Simple Internet Transition (SIT)
72 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
514 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_uninit() local
515 struct sit_net *sitn = net_generic(tunnel->net, sit_net_id); in ipip6_tunnel_uninit()
520 ipip6_tunnel_unlink(sitn, tunnel); in ipip6_tunnel_uninit()
521 ipip6_tunnel_del_prl(tunnel, NULL); in ipip6_tunnel_uninit()
523 dst_cache_reset(&tunnel->dst_cache); in ipip6_tunnel_uninit()
524 netdev_put(dev, &tunnel->dev_tracker); in ipip6_tunnel_uninit()
605 static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr, in is_spoofed_6rd() argument
609 if (check_6rd(tunnel, v6addr, &v4embed) && v4addr != v4embed) in is_spoofed_6rd()
614 /* Checks if an address matches an address on the tunnel interface.
626 static bool only_dnatted(const struct ip_tunnel *tunnel, in only_dnatted() argument
632 prefix_len = tunnel->ip6rd.prefixlen + 32 in only_dnatted()
633 - tunnel->ip6rd.relay_prefixlen; in only_dnatted()
637 return ipv6_chk_custom_prefix(v6dst, prefix_len, tunnel->dev); in only_dnatted()
643 struct ip_tunnel *tunnel) in packet_is_spoofed() argument
647 if (tunnel->dev->priv_flags & IFF_ISATAP) { in packet_is_spoofed()
648 if (!isatap_chksrc(skb, iph, tunnel)) in packet_is_spoofed()
654 if (tunnel->dev->flags & IFF_POINTOPOINT) in packet_is_spoofed()
659 if (unlikely(is_spoofed_6rd(tunnel, iph->saddr, &ipv6h->saddr))) { in packet_is_spoofed()
666 if (likely(!is_spoofed_6rd(tunnel, iph->daddr, &ipv6h->daddr))) in packet_is_spoofed()
669 if (only_dnatted(tunnel, &ipv6h->daddr)) in packet_is_spoofed()
681 struct ip_tunnel *tunnel; in ipip6_rcv() local
686 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev, in ipip6_rcv()
688 if (tunnel) { in ipip6_rcv()
689 if (tunnel->parms.iph.protocol != IPPROTO_IPV6 && in ipip6_rcv()
690 tunnel->parms.iph.protocol != 0) in ipip6_rcv()
696 skb->dev = tunnel->dev; in ipip6_rcv()
698 if (packet_is_spoofed(skb, iph, tunnel)) { in ipip6_rcv()
699 DEV_STATS_INC(tunnel->dev, rx_errors); in ipip6_rcv()
704 !net_eq(tunnel->net, dev_net(tunnel->dev)))) in ipip6_rcv()
719 DEV_STATS_INC(tunnel->dev, rx_frame_errors); in ipip6_rcv()
720 DEV_STATS_INC(tunnel->dev, rx_errors); in ipip6_rcv()
725 dev_sw_netstats_rx_add(tunnel->dev, skb->len); in ipip6_rcv()
732 /* no tunnel matched, let upstream know, ipsec may handle it */ in ipip6_rcv()
740 /* no tunnel info required for ipip. */
746 /* no tunnel info required for mplsip. */
754 struct ip_tunnel *tunnel; in sit_tunnel_rcv() local
760 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev, in sit_tunnel_rcv()
762 if (tunnel) { in sit_tunnel_rcv()
765 if (tunnel->parms.iph.protocol != ipproto && in sit_tunnel_rcv()
766 tunnel->parms.iph.protocol != 0) in sit_tunnel_rcv()
781 return ip_tunnel_rcv(tunnel, skb, tpi, NULL, log_ecn_error); in sit_tunnel_rcv()
807 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst, in check_6rd() argument
811 if (ipv6_prefix_equal(v6dst, &tunnel->ip6rd.prefix, in check_6rd()
812 tunnel->ip6rd.prefixlen)) { in check_6rd()
817 pbw0 = tunnel->ip6rd.prefixlen >> 5; in check_6rd()
818 pbi0 = tunnel->ip6rd.prefixlen & 0x1f; in check_6rd()
820 d = tunnel->ip6rd.relay_prefixlen < 32 ? in check_6rd()
822 tunnel->ip6rd.relay_prefixlen : 0; in check_6rd()
824 pbi1 = pbi0 - tunnel->ip6rd.relay_prefixlen; in check_6rd()
829 *v4dst = tunnel->ip6rd.relay_prefix | htonl(d); in check_6rd()
842 static inline __be32 try_6rd(struct ip_tunnel *tunnel, in try_6rd() argument
846 check_6rd(tunnel, v6dst, &dst); in try_6rd()
858 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_xmit() local
859 const struct iphdr *tiph = &tunnel->parms.iph; in ipip6_tunnel_xmit()
861 u8 tos = tunnel->parms.iph.tos; in ipip6_tunnel_xmit()
873 int t_hlen = tunnel->hlen + sizeof(struct iphdr); in ipip6_tunnel_xmit()
906 dst = try_6rd(tunnel, &iph6->daddr); in ipip6_tunnel_xmit()
938 flowi4_init_output(&fl4, tunnel->parms.link, tunnel->fwmark, in ipip6_tunnel_xmit()
941 sock_net_uid(tunnel->net, NULL)); in ipip6_tunnel_xmit()
943 rt = dst_cache_get_ip4(&tunnel->dst_cache, &fl4.saddr); in ipip6_tunnel_xmit()
945 rt = ip_route_output_flow(tunnel->net, &fl4, NULL); in ipip6_tunnel_xmit()
950 dst_cache_set_ip4(&tunnel->dst_cache, &rt->dst, fl4.saddr); in ipip6_tunnel_xmit()
985 if (tunnel->parms.iph.daddr) in ipip6_tunnel_xmit()
995 if (tunnel->err_count > 0) { in ipip6_tunnel_xmit()
997 tunnel->err_time + IPTUNNEL_ERR_TIMEO)) { in ipip6_tunnel_xmit()
998 tunnel->err_count--; in ipip6_tunnel_xmit()
1001 tunnel->err_count = 0; in ipip6_tunnel_xmit()
1029 if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0) { in ipip6_tunnel_xmit()
1037 df, !net_eq(tunnel->net, dev_net(dev))); in ipip6_tunnel_xmit()
1051 struct ip_tunnel *tunnel = netdev_priv(dev); in sit_tunnel_xmit__() local
1052 const struct iphdr *tiph = &tunnel->parms.iph; in sit_tunnel_xmit__()
1100 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_bind_dev() local
1101 int t_hlen = tunnel->hlen + sizeof(struct iphdr); in ipip6_tunnel_bind_dev()
1107 iph = &tunnel->parms.iph; in ipip6_tunnel_bind_dev()
1110 struct rtable *rt = ip_route_output_ports(tunnel->net, &fl4, in ipip6_tunnel_bind_dev()
1116 tunnel->parms.link); in ipip6_tunnel_bind_dev()
1125 if (!tdev && tunnel->parms.link) in ipip6_tunnel_bind_dev()
1126 tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link); in ipip6_tunnel_bind_dev()
1411 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_dev_free() local
1413 dst_cache_destroy(&tunnel->dst_cache); in ipip6_dev_free()
1424 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_setup() local
1425 int t_hlen = tunnel->hlen + sizeof(struct iphdr); in ipip6_tunnel_setup()
1448 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_init() local
1451 tunnel->dev = dev; in ipip6_tunnel_init()
1452 tunnel->net = dev_net(dev); in ipip6_tunnel_init()
1453 strcpy(tunnel->parms.name, dev->name); in ipip6_tunnel_init()
1457 err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL); in ipip6_tunnel_init()
1461 netdev_hold(dev, &tunnel->dev_tracker, GFP_KERNEL); in ipip6_tunnel_init()
1468 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_fb_tunnel_init() local
1469 struct iphdr *iph = &tunnel->parms.iph; in ipip6_fb_tunnel_init()
1478 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel); in ipip6_fb_tunnel_init()
1693 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_fill_info() local
1694 struct ip_tunnel_parm_kern *parm = &tunnel->parms; in ipip6_fill_info()
1706 nla_put_u32(skb, IFLA_IPTUN_FWMARK, tunnel->fwmark)) in ipip6_fill_info()
1711 &tunnel->ip6rd.prefix) || in ipip6_fill_info()
1713 tunnel->ip6rd.relay_prefix) || in ipip6_fill_info()
1715 tunnel->ip6rd.prefixlen) || in ipip6_fill_info()
1717 tunnel->ip6rd.relay_prefixlen)) in ipip6_fill_info()
1722 tunnel->encap.type) || in ipip6_fill_info()
1724 tunnel->encap.sport) || in ipip6_fill_info()
1726 tunnel->encap.dport) || in ipip6_fill_info()
1728 tunnel->encap.flags)) in ipip6_fill_info()
1957 MODULE_DESCRIPTION("IPv6-in-IPv4 tunnel SIT driver");