Lines Matching refs:tunnel
71 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
509 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_uninit() local
510 struct sit_net *sitn = net_generic(tunnel->net, sit_net_id); in ipip6_tunnel_uninit()
515 ipip6_tunnel_unlink(sitn, tunnel); in ipip6_tunnel_uninit()
516 ipip6_tunnel_del_prl(tunnel, NULL); in ipip6_tunnel_uninit()
518 dst_cache_reset(&tunnel->dst_cache); in ipip6_tunnel_uninit()
600 static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr, in is_spoofed_6rd() argument
604 if (check_6rd(tunnel, v6addr, &v4embed) && v4addr != v4embed) in is_spoofed_6rd()
621 static bool only_dnatted(const struct ip_tunnel *tunnel, in only_dnatted() argument
627 prefix_len = tunnel->ip6rd.prefixlen + 32 in only_dnatted()
628 - tunnel->ip6rd.relay_prefixlen; in only_dnatted()
632 return ipv6_chk_custom_prefix(v6dst, prefix_len, tunnel->dev); in only_dnatted()
638 struct ip_tunnel *tunnel) in packet_is_spoofed() argument
642 if (tunnel->dev->priv_flags & IFF_ISATAP) { in packet_is_spoofed()
643 if (!isatap_chksrc(skb, iph, tunnel)) in packet_is_spoofed()
649 if (tunnel->dev->flags & IFF_POINTOPOINT) in packet_is_spoofed()
654 if (unlikely(is_spoofed_6rd(tunnel, iph->saddr, &ipv6h->saddr))) { in packet_is_spoofed()
661 if (likely(!is_spoofed_6rd(tunnel, iph->daddr, &ipv6h->daddr))) in packet_is_spoofed()
664 if (only_dnatted(tunnel, &ipv6h->daddr)) in packet_is_spoofed()
676 struct ip_tunnel *tunnel; in ipip6_rcv() local
681 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev, in ipip6_rcv()
683 if (tunnel) { in ipip6_rcv()
686 if (tunnel->parms.iph.protocol != IPPROTO_IPV6 && in ipip6_rcv()
687 tunnel->parms.iph.protocol != 0) in ipip6_rcv()
693 skb->dev = tunnel->dev; in ipip6_rcv()
695 if (packet_is_spoofed(skb, iph, tunnel)) { in ipip6_rcv()
696 tunnel->dev->stats.rx_errors++; in ipip6_rcv()
701 !net_eq(tunnel->net, dev_net(tunnel->dev)))) in ipip6_rcv()
714 ++tunnel->dev->stats.rx_frame_errors; in ipip6_rcv()
715 ++tunnel->dev->stats.rx_errors; in ipip6_rcv()
720 tstats = this_cpu_ptr(tunnel->dev->tstats); in ipip6_rcv()
753 struct ip_tunnel *tunnel; in sit_tunnel_rcv() local
759 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev, in sit_tunnel_rcv()
761 if (tunnel) { in sit_tunnel_rcv()
764 if (tunnel->parms.iph.protocol != ipproto && in sit_tunnel_rcv()
765 tunnel->parms.iph.protocol != 0) in sit_tunnel_rcv()
778 return ip_tunnel_rcv(tunnel, skb, tpi, NULL, log_ecn_error); in sit_tunnel_rcv()
804 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst, in check_6rd() argument
808 if (ipv6_prefix_equal(v6dst, &tunnel->ip6rd.prefix, in check_6rd()
809 tunnel->ip6rd.prefixlen)) { in check_6rd()
814 pbw0 = tunnel->ip6rd.prefixlen >> 5; in check_6rd()
815 pbi0 = tunnel->ip6rd.prefixlen & 0x1f; in check_6rd()
817 d = tunnel->ip6rd.relay_prefixlen < 32 ? in check_6rd()
819 tunnel->ip6rd.relay_prefixlen : 0; in check_6rd()
821 pbi1 = pbi0 - tunnel->ip6rd.relay_prefixlen; in check_6rd()
826 *v4dst = tunnel->ip6rd.relay_prefix | htonl(d); in check_6rd()
839 static inline __be32 try_6rd(struct ip_tunnel *tunnel, in try_6rd() argument
843 check_6rd(tunnel, v6dst, &dst); in try_6rd()
855 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_xmit() local
856 const struct iphdr *tiph = &tunnel->parms.iph; in ipip6_tunnel_xmit()
858 u8 tos = tunnel->parms.iph.tos; in ipip6_tunnel_xmit()
870 int t_hlen = tunnel->hlen + sizeof(struct iphdr); in ipip6_tunnel_xmit()
903 dst = try_6rd(tunnel, &iph6->daddr); in ipip6_tunnel_xmit()
935 flowi4_init_output(&fl4, tunnel->parms.link, tunnel->fwmark, in ipip6_tunnel_xmit()
938 sock_net_uid(tunnel->net, NULL)); in ipip6_tunnel_xmit()
940 rt = dst_cache_get_ip4(&tunnel->dst_cache, &fl4.saddr); in ipip6_tunnel_xmit()
942 rt = ip_route_output_flow(tunnel->net, &fl4, NULL); in ipip6_tunnel_xmit()
947 dst_cache_set_ip4(&tunnel->dst_cache, &rt->dst, fl4.saddr); in ipip6_tunnel_xmit()
982 if (tunnel->parms.iph.daddr) in ipip6_tunnel_xmit()
992 if (tunnel->err_count > 0) { in ipip6_tunnel_xmit()
994 tunnel->err_time + IPTUNNEL_ERR_TIMEO)) { in ipip6_tunnel_xmit()
995 tunnel->err_count--; in ipip6_tunnel_xmit()
998 tunnel->err_count = 0; in ipip6_tunnel_xmit()
1026 if (ip_tunnel_encap(skb, tunnel, &protocol, &fl4) < 0) { in ipip6_tunnel_xmit()
1034 df, !net_eq(tunnel->net, dev_net(dev))); in ipip6_tunnel_xmit()
1048 struct ip_tunnel *tunnel = netdev_priv(dev); in sit_tunnel_xmit__() local
1049 const struct iphdr *tiph = &tunnel->parms.iph; in sit_tunnel_xmit__()
1098 struct ip_tunnel *tunnel; in ipip6_tunnel_bind_dev() local
1102 tunnel = netdev_priv(dev); in ipip6_tunnel_bind_dev()
1103 iph = &tunnel->parms.iph; in ipip6_tunnel_bind_dev()
1106 struct rtable *rt = ip_route_output_ports(tunnel->net, &fl4, in ipip6_tunnel_bind_dev()
1112 tunnel->parms.link); in ipip6_tunnel_bind_dev()
1121 if (!tdev && tunnel->parms.link) in ipip6_tunnel_bind_dev()
1122 tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link); in ipip6_tunnel_bind_dev()
1125 int t_hlen = tunnel->hlen + sizeof(struct iphdr); in ipip6_tunnel_bind_dev()
1403 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_dev_free() local
1405 dst_cache_destroy(&tunnel->dst_cache); in ipip6_dev_free()
1417 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_setup() local
1418 int t_hlen = tunnel->hlen + sizeof(struct iphdr); in ipip6_tunnel_setup()
1439 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_tunnel_init() local
1442 tunnel->dev = dev; in ipip6_tunnel_init()
1443 tunnel->net = dev_net(dev); in ipip6_tunnel_init()
1444 strcpy(tunnel->parms.name, dev->name); in ipip6_tunnel_init()
1451 err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL); in ipip6_tunnel_init()
1463 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_fb_tunnel_init() local
1464 struct iphdr *iph = &tunnel->parms.iph; in ipip6_fb_tunnel_init()
1473 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel); in ipip6_fb_tunnel_init()
1747 struct ip_tunnel *tunnel = netdev_priv(dev); in ipip6_fill_info() local
1748 struct ip_tunnel_parm *parm = &tunnel->parms; in ipip6_fill_info()
1759 nla_put_u32(skb, IFLA_IPTUN_FWMARK, tunnel->fwmark)) in ipip6_fill_info()
1764 &tunnel->ip6rd.prefix) || in ipip6_fill_info()
1766 tunnel->ip6rd.relay_prefix) || in ipip6_fill_info()
1768 tunnel->ip6rd.prefixlen) || in ipip6_fill_info()
1770 tunnel->ip6rd.relay_prefixlen)) in ipip6_fill_info()
1775 tunnel->encap.type) || in ipip6_fill_info()
1777 tunnel->encap.sport) || in ipip6_fill_info()
1779 tunnel->encap.dport) || in ipip6_fill_info()
1781 tunnel->encap.flags)) in ipip6_fill_info()