Lines Matching refs:tunnel
3 * IPv6 over IPv4 tunnel device - Simple Internet Transition (SIT)
71 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
512 struct ip_tunnel *tunnel = netdev_priv(dev);
513 struct sit_net *sitn = net_generic(tunnel->net, sit_net_id);
518 ipip6_tunnel_unlink(sitn, tunnel);
519 ipip6_tunnel_del_prl(tunnel, NULL);
521 dst_cache_reset(&tunnel->dst_cache);
522 netdev_put(dev, &tunnel->dev_tracker);
603 static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr,
607 if (check_6rd(tunnel, v6addr, &v4embed) && v4addr != v4embed)
612 /* Checks if an address matches an address on the tunnel interface.
624 static bool only_dnatted(const struct ip_tunnel *tunnel,
630 prefix_len = tunnel->ip6rd.prefixlen + 32
631 - tunnel->ip6rd.relay_prefixlen;
635 return ipv6_chk_custom_prefix(v6dst, prefix_len, tunnel->dev);
641 struct ip_tunnel *tunnel)
645 if (tunnel->dev->priv_flags & IFF_ISATAP) {
646 if (!isatap_chksrc(skb, iph, tunnel))
652 if (tunnel->dev->flags & IFF_POINTOPOINT)
657 if (unlikely(is_spoofed_6rd(tunnel, iph->saddr, &ipv6h->saddr))) {
664 if (likely(!is_spoofed_6rd(tunnel, iph->daddr, &ipv6h->daddr)))
667 if (only_dnatted(tunnel, &ipv6h->daddr))
679 struct ip_tunnel *tunnel;
684 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
686 if (tunnel) {
687 if (tunnel->parms.iph.protocol != IPPROTO_IPV6 &&
688 tunnel->parms.iph.protocol != 0)
694 skb->dev = tunnel->dev;
696 if (packet_is_spoofed(skb, iph, tunnel)) {
697 DEV_STATS_INC(tunnel->dev, rx_errors);
702 !net_eq(tunnel->net, dev_net(tunnel->dev))))
717 DEV_STATS_INC(tunnel->dev, rx_frame_errors);
718 DEV_STATS_INC(tunnel->dev, rx_errors);
723 dev_sw_netstats_rx_add(tunnel->dev, skb->len);
730 /* no tunnel matched, let upstream know, ipsec may handle it */
738 /* no tunnel info required for ipip. */
744 /* no tunnel info required for mplsip. */
752 struct ip_tunnel *tunnel;
758 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
760 if (tunnel) {
763 if (tunnel->parms.iph.protocol != ipproto &&
764 tunnel->parms.iph.protocol != 0)
779 return ip_tunnel_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
805 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
809 if (ipv6_prefix_equal(v6dst, &tunnel->ip6rd.prefix,
810 tunnel->ip6rd.prefixlen)) {
815 pbw0 = tunnel->ip6rd.prefixlen >> 5;
816 pbi0 = tunnel->ip6rd.prefixlen & 0x1f;
818 d = tunnel->ip6rd.relay_prefixlen < 32 ?
820 tunnel->ip6rd.relay_prefixlen : 0;
822 pbi1 = pbi0 - tunnel->ip6rd.relay_prefixlen;
827 *v4dst = tunnel->ip6rd.relay_prefix | htonl(d);
840 static inline __be32 try_6rd(struct ip_tunnel *tunnel,
844 check_6rd(tunnel, v6dst, &dst);
856 struct ip_tunnel *tunnel = netdev_priv(dev);
857 const struct iphdr *tiph = &tunnel->parms.iph;
859 u8 tos = tunnel->parms.iph.tos;
871 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
904 dst = try_6rd(tunnel, &iph6->daddr);
936 flowi4_init_output(&fl4, tunnel->parms.link, tunnel->fwmark,
939 sock_net_uid(tunnel->net, NULL));
941 rt = dst_cache_get_ip4(&tunnel->dst_cache, &fl4.saddr);
943 rt = ip_route_output_flow(tunnel->net, &fl4, NULL);
948 dst_cache_set_ip4(&tunnel->dst_cache, &rt->dst, fl4.saddr);
983 if (tunnel->parms.iph.daddr)
993 if (tunnel->err_count > 0) {
995 tunnel->err_time + IPTUNNEL_ERR_TIMEO)) {
996 tunnel->err_count--;
999 tunnel->err_count = 0;
1027 if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0) {
1035 df, !net_eq(tunnel->net, dev_net(dev)));
1049 struct ip_tunnel *tunnel = netdev_priv(dev);
1050 const struct iphdr *tiph = &tunnel->parms.iph;
1098 struct ip_tunnel *tunnel = netdev_priv(dev);
1099 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
1105 iph = &tunnel->parms.iph;
1108 struct rtable *rt = ip_route_output_ports(tunnel->net, &fl4,
1114 tunnel->parms.link);
1123 if (!tdev && tunnel->parms.link)
1124 tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link);
1408 struct ip_tunnel *tunnel = netdev_priv(dev);
1410 dst_cache_destroy(&tunnel->dst_cache);
1422 struct ip_tunnel *tunnel = netdev_priv(dev);
1423 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
1444 struct ip_tunnel *tunnel = netdev_priv(dev);
1447 tunnel->dev = dev;
1448 tunnel->net = dev_net(dev);
1449 strcpy(tunnel->parms.name, dev->name);
1456 err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL);
1462 netdev_hold(dev, &tunnel->dev_tracker, GFP_KERNEL);
1468 struct ip_tunnel *tunnel = netdev_priv(dev);
1469 struct iphdr *iph = &tunnel->parms.iph;
1478 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
1693 struct ip_tunnel *tunnel = netdev_priv(dev);
1694 struct ip_tunnel_parm *parm = &tunnel->parms;
1705 nla_put_u32(skb, IFLA_IPTUN_FWMARK, tunnel->fwmark))
1710 &tunnel->ip6rd.prefix) ||
1712 tunnel->ip6rd.relay_prefix) ||
1714 tunnel->ip6rd.prefixlen) ||
1716 tunnel->ip6rd.relay_prefixlen))
1721 tunnel->encap.type) ||
1723 tunnel->encap.sport) ||
1725 tunnel->encap.dport) ||
1727 tunnel->encap.flags))