Lines Matching refs:tunnel
71 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
512 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_uninit() local
513 struct sit_net *sitn = net_generic(tunnel->net, sit_net_id); in ipip6_tunnel_uninit()
518 ipip6_tunnel_unlink(sitn, tunnel); in ipip6_tunnel_uninit()
519 ipip6_tunnel_del_prl(tunnel, NULL); in ipip6_tunnel_uninit()
521 dst_cache_reset(&tunnel->dst_cache); in ipip6_tunnel_uninit()
522 netdev_put(dev, &tunnel->dev_tracker); in ipip6_tunnel_uninit()
603 static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr, in is_spoofed_6rd() argument
607 if (check_6rd(tunnel, v6addr, &v4embed) && v4addr != v4embed) in is_spoofed_6rd()
624 static bool only_dnatted(const struct ip_tunnel *tunnel, in only_dnatted() argument
630 prefix_len = tunnel->ip6rd.prefixlen + 32 in only_dnatted()
631 - tunnel->ip6rd.relay_prefixlen; in only_dnatted()
635 return ipv6_chk_custom_prefix(v6dst, prefix_len, tunnel->dev); in only_dnatted()
641 struct ip_tunnel *tunnel) in packet_is_spoofed() argument
645 if (tunnel->dev->priv_flags & IFF_ISATAP) { in packet_is_spoofed()
646 if (!isatap_chksrc(skb, iph, tunnel)) in packet_is_spoofed()
652 if (tunnel->dev->flags & IFF_POINTOPOINT) in packet_is_spoofed()
657 if (unlikely(is_spoofed_6rd(tunnel, iph->saddr, &ipv6h->saddr))) { in packet_is_spoofed()
664 if (likely(!is_spoofed_6rd(tunnel, iph->daddr, &ipv6h->daddr))) in packet_is_spoofed()
667 if (only_dnatted(tunnel, &ipv6h->daddr)) in packet_is_spoofed()
679 struct ip_tunnel *tunnel; in ipip6_rcv() local
684 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev, in ipip6_rcv()
686 if (tunnel) { in ipip6_rcv()
687 if (tunnel->parms.iph.protocol != IPPROTO_IPV6 && in ipip6_rcv()
688 tunnel->parms.iph.protocol != 0) in ipip6_rcv()
694 skb->dev = tunnel->dev; in ipip6_rcv()
696 if (packet_is_spoofed(skb, iph, tunnel)) { in ipip6_rcv()
697 DEV_STATS_INC(tunnel->dev, rx_errors); in ipip6_rcv()
702 !net_eq(tunnel->net, dev_net(tunnel->dev)))) in ipip6_rcv()
717 DEV_STATS_INC(tunnel->dev, rx_frame_errors); in ipip6_rcv()
718 DEV_STATS_INC(tunnel->dev, rx_errors); in ipip6_rcv()
723 dev_sw_netstats_rx_add(tunnel->dev, skb->len); in ipip6_rcv()
752 struct ip_tunnel *tunnel; in sit_tunnel_rcv() local
758 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev, in sit_tunnel_rcv()
760 if (tunnel) { in sit_tunnel_rcv()
763 if (tunnel->parms.iph.protocol != ipproto && in sit_tunnel_rcv()
764 tunnel->parms.iph.protocol != 0) in sit_tunnel_rcv()
779 return ip_tunnel_rcv(tunnel, skb, tpi, NULL, log_ecn_error); in sit_tunnel_rcv()
805 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst, in check_6rd() argument
809 if (ipv6_prefix_equal(v6dst, &tunnel->ip6rd.prefix, in check_6rd()
810 tunnel->ip6rd.prefixlen)) { in check_6rd()
815 pbw0 = tunnel->ip6rd.prefixlen >> 5; in check_6rd()
816 pbi0 = tunnel->ip6rd.prefixlen & 0x1f; in check_6rd()
818 d = tunnel->ip6rd.relay_prefixlen < 32 ? in check_6rd()
820 tunnel->ip6rd.relay_prefixlen : 0; in check_6rd()
822 pbi1 = pbi0 - tunnel->ip6rd.relay_prefixlen; in check_6rd()
827 *v4dst = tunnel->ip6rd.relay_prefix | htonl(d); in check_6rd()
840 static inline __be32 try_6rd(struct ip_tunnel *tunnel, in try_6rd() argument
844 check_6rd(tunnel, v6dst, &dst); in try_6rd()
856 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_xmit() local
857 const struct iphdr *tiph = &tunnel->parms.iph; in ipip6_tunnel_xmit()
859 u8 tos = tunnel->parms.iph.tos; in ipip6_tunnel_xmit()
871 int t_hlen = tunnel->hlen + sizeof(struct iphdr); in ipip6_tunnel_xmit()
904 dst = try_6rd(tunnel, &iph6->daddr); in ipip6_tunnel_xmit()
936 flowi4_init_output(&fl4, tunnel->parms.link, tunnel->fwmark, in ipip6_tunnel_xmit()
939 sock_net_uid(tunnel->net, NULL)); in ipip6_tunnel_xmit()
941 rt = dst_cache_get_ip4(&tunnel->dst_cache, &fl4.saddr); in ipip6_tunnel_xmit()
943 rt = ip_route_output_flow(tunnel->net, &fl4, NULL); in ipip6_tunnel_xmit()
948 dst_cache_set_ip4(&tunnel->dst_cache, &rt->dst, fl4.saddr); in ipip6_tunnel_xmit()
983 if (tunnel->parms.iph.daddr) in ipip6_tunnel_xmit()
993 if (tunnel->err_count > 0) { in ipip6_tunnel_xmit()
995 tunnel->err_time + IPTUNNEL_ERR_TIMEO)) { in ipip6_tunnel_xmit()
996 tunnel->err_count--; in ipip6_tunnel_xmit()
999 tunnel->err_count = 0; in ipip6_tunnel_xmit()
1027 if (ip_tunnel_encap(skb, tunnel, &protocol, &fl4) < 0) { in ipip6_tunnel_xmit()
1035 df, !net_eq(tunnel->net, dev_net(dev))); in ipip6_tunnel_xmit()
1049 struct ip_tunnel *tunnel = netdev_priv(dev); in sit_tunnel_xmit__() local
1050 const struct iphdr *tiph = &tunnel->parms.iph; in sit_tunnel_xmit__()
1098 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_bind_dev() local
1099 int t_hlen = tunnel->hlen + sizeof(struct iphdr); in ipip6_tunnel_bind_dev()
1105 iph = &tunnel->parms.iph; in ipip6_tunnel_bind_dev()
1108 struct rtable *rt = ip_route_output_ports(tunnel->net, &fl4, in ipip6_tunnel_bind_dev()
1114 tunnel->parms.link); in ipip6_tunnel_bind_dev()
1123 if (!tdev && tunnel->parms.link) in ipip6_tunnel_bind_dev()
1124 tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link); in ipip6_tunnel_bind_dev()
1408 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_dev_free() local
1410 dst_cache_destroy(&tunnel->dst_cache); in ipip6_dev_free()
1422 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_setup() local
1423 int t_hlen = tunnel->hlen + sizeof(struct iphdr); in ipip6_tunnel_setup()
1444 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_init() local
1447 tunnel->dev = dev; in ipip6_tunnel_init()
1448 tunnel->net = dev_net(dev); in ipip6_tunnel_init()
1449 strcpy(tunnel->parms.name, dev->name); in ipip6_tunnel_init()
1456 err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL); in ipip6_tunnel_init()
1462 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 *parm = &tunnel->parms; in ipip6_fill_info()
1705 nla_put_u32(skb, IFLA_IPTUN_FWMARK, tunnel->fwmark)) in ipip6_fill_info()
1710 &tunnel->ip6rd.prefix) || in ipip6_fill_info()
1712 tunnel->ip6rd.relay_prefix) || in ipip6_fill_info()
1714 tunnel->ip6rd.prefixlen) || in ipip6_fill_info()
1716 tunnel->ip6rd.relay_prefixlen)) in ipip6_fill_info()
1721 tunnel->encap.type) || in ipip6_fill_info()
1723 tunnel->encap.sport) || in ipip6_fill_info()
1725 tunnel->encap.dport) || in ipip6_fill_info()
1727 tunnel->encap.flags)) in ipip6_fill_info()