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,
509 struct ip_tunnel *tunnel = netdev_priv(dev);
510 struct sit_net *sitn = net_generic(tunnel->net, sit_net_id);
515 ipip6_tunnel_unlink(sitn, tunnel);
516 ipip6_tunnel_del_prl(tunnel, NULL);
518 dst_cache_reset(&tunnel->dst_cache);
600 static inline bool is_spoofed_6rd(struct ip_tunnel *tunnel, const __be32 v4addr,
604 if (check_6rd(tunnel, v6addr, &v4embed) && v4addr != v4embed)
609 /* Checks if an address matches an address on the tunnel interface.
621 static bool only_dnatted(const struct ip_tunnel *tunnel,
627 prefix_len = tunnel->ip6rd.prefixlen + 32
628 - tunnel->ip6rd.relay_prefixlen;
632 return ipv6_chk_custom_prefix(v6dst, prefix_len, tunnel->dev);
638 struct ip_tunnel *tunnel)
642 if (tunnel->dev->priv_flags & IFF_ISATAP) {
643 if (!isatap_chksrc(skb, iph, tunnel))
649 if (tunnel->dev->flags & IFF_POINTOPOINT)
654 if (unlikely(is_spoofed_6rd(tunnel, iph->saddr, &ipv6h->saddr))) {
661 if (likely(!is_spoofed_6rd(tunnel, iph->daddr, &ipv6h->daddr)))
664 if (only_dnatted(tunnel, &ipv6h->daddr))
676 struct ip_tunnel *tunnel;
681 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
683 if (tunnel) {
686 if (tunnel->parms.iph.protocol != IPPROTO_IPV6 &&
687 tunnel->parms.iph.protocol != 0)
693 skb->dev = tunnel->dev;
695 if (packet_is_spoofed(skb, iph, tunnel)) {
696 tunnel->dev->stats.rx_errors++;
701 !net_eq(tunnel->net, dev_net(tunnel->dev))))
714 ++tunnel->dev->stats.rx_frame_errors;
715 ++tunnel->dev->stats.rx_errors;
720 tstats = this_cpu_ptr(tunnel->dev->tstats);
731 /* no tunnel matched, let upstream know, ipsec may handle it */
739 /* no tunnel info required for ipip. */
745 /* no tunnel info required for mplsip. */
753 struct ip_tunnel *tunnel;
759 tunnel = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev,
761 if (tunnel) {
764 if (tunnel->parms.iph.protocol != ipproto &&
765 tunnel->parms.iph.protocol != 0)
778 return ip_tunnel_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
804 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
808 if (ipv6_prefix_equal(v6dst, &tunnel->ip6rd.prefix,
809 tunnel->ip6rd.prefixlen)) {
814 pbw0 = tunnel->ip6rd.prefixlen >> 5;
815 pbi0 = tunnel->ip6rd.prefixlen & 0x1f;
817 d = tunnel->ip6rd.relay_prefixlen < 32 ?
819 tunnel->ip6rd.relay_prefixlen : 0;
821 pbi1 = pbi0 - tunnel->ip6rd.relay_prefixlen;
826 *v4dst = tunnel->ip6rd.relay_prefix | htonl(d);
839 static inline __be32 try_6rd(struct ip_tunnel *tunnel,
843 check_6rd(tunnel, v6dst, &dst);
855 struct ip_tunnel *tunnel = netdev_priv(dev);
856 const struct iphdr *tiph = &tunnel->parms.iph;
858 u8 tos = tunnel->parms.iph.tos;
870 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
903 dst = try_6rd(tunnel, &iph6->daddr);
935 flowi4_init_output(&fl4, tunnel->parms.link, tunnel->fwmark,
938 sock_net_uid(tunnel->net, NULL));
940 rt = dst_cache_get_ip4(&tunnel->dst_cache, &fl4.saddr);
942 rt = ip_route_output_flow(tunnel->net, &fl4, NULL);
947 dst_cache_set_ip4(&tunnel->dst_cache, &rt->dst, fl4.saddr);
982 if (tunnel->parms.iph.daddr)
992 if (tunnel->err_count > 0) {
994 tunnel->err_time + IPTUNNEL_ERR_TIMEO)) {
995 tunnel->err_count--;
998 tunnel->err_count = 0;
1026 if (ip_tunnel_encap(skb, tunnel, &protocol, &fl4) < 0) {
1034 df, !net_eq(tunnel->net, dev_net(dev)));
1048 struct ip_tunnel *tunnel = netdev_priv(dev);
1049 const struct iphdr *tiph = &tunnel->parms.iph;
1097 struct ip_tunnel *tunnel = netdev_priv(dev);
1098 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
1104 iph = &tunnel->parms.iph;
1107 struct rtable *rt = ip_route_output_ports(tunnel->net, &fl4,
1113 tunnel->parms.link);
1122 if (!tdev && tunnel->parms.link)
1123 tdev = __dev_get_by_index(tunnel->net, tunnel->parms.link);
1405 struct ip_tunnel *tunnel = netdev_priv(dev);
1407 dst_cache_destroy(&tunnel->dst_cache);
1419 struct ip_tunnel *tunnel = netdev_priv(dev);
1420 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
1441 struct ip_tunnel *tunnel = netdev_priv(dev);
1444 tunnel->dev = dev;
1445 tunnel->net = dev_net(dev);
1446 strcpy(tunnel->parms.name, dev->name);
1453 err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL);
1465 struct ip_tunnel *tunnel = netdev_priv(dev);
1466 struct iphdr *iph = &tunnel->parms.iph;
1475 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
1749 struct ip_tunnel *tunnel = netdev_priv(dev);
1750 struct ip_tunnel_parm *parm = &tunnel->parms;
1761 nla_put_u32(skb, IFLA_IPTUN_FWMARK, tunnel->fwmark))
1766 &tunnel->ip6rd.prefix) ||
1768 tunnel->ip6rd.relay_prefix) ||
1770 tunnel->ip6rd.prefixlen) ||
1772 tunnel->ip6rd.relay_prefixlen))
1777 tunnel->encap.type) ||
1779 tunnel->encap.sport) ||
1781 tunnel->encap.dport) ||
1783 tunnel->encap.flags))