Lines Matching refs:t

88 	struct ip_tunnel *t = netdev_priv(dev);  in dev_to_sit_net()  local
90 return net_generic(t->net, sit_net_id); in dev_to_sit_net()
103 struct ip_tunnel *t; in ipip6_tunnel_lookup() local
107 for_each_ip_tunnel_rcu(t, sitn->tunnels_r_l[h0 ^ h1]) { in ipip6_tunnel_lookup()
108 if (local == t->parms.iph.saddr && in ipip6_tunnel_lookup()
109 remote == t->parms.iph.daddr && in ipip6_tunnel_lookup()
110 (!dev || !t->parms.link || ifindex == t->parms.link || in ipip6_tunnel_lookup()
111 sifindex == t->parms.link) && in ipip6_tunnel_lookup()
112 (t->dev->flags & IFF_UP)) in ipip6_tunnel_lookup()
113 return t; in ipip6_tunnel_lookup()
115 for_each_ip_tunnel_rcu(t, sitn->tunnels_r[h0]) { in ipip6_tunnel_lookup()
116 if (remote == t->parms.iph.daddr && in ipip6_tunnel_lookup()
117 (!dev || !t->parms.link || ifindex == t->parms.link || in ipip6_tunnel_lookup()
118 sifindex == t->parms.link) && in ipip6_tunnel_lookup()
119 (t->dev->flags & IFF_UP)) in ipip6_tunnel_lookup()
120 return t; in ipip6_tunnel_lookup()
122 for_each_ip_tunnel_rcu(t, sitn->tunnels_l[h1]) { in ipip6_tunnel_lookup()
123 if (local == t->parms.iph.saddr && in ipip6_tunnel_lookup()
124 (!dev || !t->parms.link || ifindex == t->parms.link || in ipip6_tunnel_lookup()
125 sifindex == t->parms.link) && in ipip6_tunnel_lookup()
126 (t->dev->flags & IFF_UP)) in ipip6_tunnel_lookup()
127 return t; in ipip6_tunnel_lookup()
129 t = rcu_dereference(sitn->tunnels_wc[0]); in ipip6_tunnel_lookup()
130 if (t && (t->dev->flags & IFF_UP)) in ipip6_tunnel_lookup()
131 return t; in ipip6_tunnel_lookup()
155 struct ip_tunnel *t) in ipip6_bucket() argument
157 return __ipip6_bucket(sitn, &t->parms); in ipip6_bucket()
160 static void ipip6_tunnel_unlink(struct sit_net *sitn, struct ip_tunnel *t) in ipip6_tunnel_unlink() argument
165 for (tp = ipip6_bucket(sitn, t); in ipip6_tunnel_unlink()
168 if (t == iter) { in ipip6_tunnel_unlink()
169 rcu_assign_pointer(*tp, t->next); in ipip6_tunnel_unlink()
175 static void ipip6_tunnel_link(struct sit_net *sitn, struct ip_tunnel *t) in ipip6_tunnel_link() argument
177 struct ip_tunnel __rcu **tp = ipip6_bucket(sitn, t); in ipip6_tunnel_link()
179 rcu_assign_pointer(t->next, rtnl_dereference(*tp)); in ipip6_tunnel_link()
180 rcu_assign_pointer(*tp, t); in ipip6_tunnel_link()
186 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_clone_6rd() local
189 ipv6_addr_set(&t->ip6rd.prefix, htonl(0x20020000), 0, 0, 0); in ipip6_tunnel_clone_6rd()
190 t->ip6rd.relay_prefix = 0; in ipip6_tunnel_clone_6rd()
191 t->ip6rd.prefixlen = 16; in ipip6_tunnel_clone_6rd()
192 t->ip6rd.relay_prefixlen = 0; in ipip6_tunnel_clone_6rd()
195 memcpy(&t->ip6rd, &t0->ip6rd, sizeof(t->ip6rd)); in ipip6_tunnel_clone_6rd()
202 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_create() local
207 __dev_addr_set(dev, &t->parms.iph.saddr, 4); in ipip6_tunnel_create()
208 memcpy(dev->broadcast, &t->parms.iph.daddr, 4); in ipip6_tunnel_create()
210 if ((__force u16)t->parms.i_flags & SIT_ISATAP) in ipip6_tunnel_create()
221 ipip6_tunnel_link(sitn, t); in ipip6_tunnel_create()
233 struct ip_tunnel *t, *nt; in ipip6_tunnel_locate() local
240 (t = rtnl_dereference(*tp)) != NULL; in ipip6_tunnel_locate()
241 tp = &t->next) { in ipip6_tunnel_locate()
242 if (local == t->parms.iph.saddr && in ipip6_tunnel_locate()
243 remote == t->parms.iph.daddr && in ipip6_tunnel_locate()
244 parms->link == t->parms.link) { in ipip6_tunnel_locate()
248 return t; in ipip6_tunnel_locate()
261 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, in ipip6_tunnel_locate()
291 __ipip6_tunnel_locate_prl(struct ip_tunnel *t, __be32 addr) in __ipip6_tunnel_locate_prl() argument
295 for_each_prl_rcu(t->prl) in __ipip6_tunnel_locate_prl()
304 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_get_prl() local
326 ca = min(t->prl_count, cmax); in ipip6_tunnel_get_prl()
343 for_each_prl_rcu(t->prl) { in ipip6_tunnel_get_prl()
368 ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg) in ipip6_tunnel_add_prl() argument
378 for (p = rtnl_dereference(t->prl); p; p = rtnl_dereference(p->next)) { in ipip6_tunnel_add_prl()
400 p->next = t->prl; in ipip6_tunnel_add_prl()
403 t->prl_count++; in ipip6_tunnel_add_prl()
404 rcu_assign_pointer(t->prl, p); in ipip6_tunnel_add_prl()
422 ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) in ipip6_tunnel_del_prl() argument
431 for (p = &t->prl; in ipip6_tunnel_del_prl()
437 t->prl_count--; in ipip6_tunnel_del_prl()
443 x = rtnl_dereference(t->prl); in ipip6_tunnel_del_prl()
445 t->prl_count = 0; in ipip6_tunnel_del_prl()
447 t->prl = NULL; in ipip6_tunnel_del_prl()
457 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_prl_ctl() local
461 if (!ns_capable(t->net->user_ns, CAP_NET_ADMIN)) in ipip6_tunnel_prl_ctl()
471 err = ipip6_tunnel_del_prl(t, &prl); in ipip6_tunnel_prl_ctl()
475 err = ipip6_tunnel_add_prl(t, &prl, cmd == SIOCCHGPRL); in ipip6_tunnel_prl_ctl()
478 dst_cache_reset(&t->dst_cache); in ipip6_tunnel_prl_ctl()
484 isatap_chksrc(struct sk_buff *skb, const struct iphdr *iph, struct ip_tunnel *t) in isatap_chksrc() argument
490 p = __ipip6_tunnel_locate_prl(t, iph->saddr); in isatap_chksrc()
501 ipv6_chk_prefix(addr6, t->dev)) in isatap_chksrc()
531 struct ip_tunnel *t; in ipip6_err() local
565 t = ipip6_tunnel_lookup(dev_net(skb->dev), skb->dev, in ipip6_err()
567 if (!t) in ipip6_err()
572 t->parms.link, iph->protocol); in ipip6_err()
577 ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, in ipip6_err()
588 if (t->parms.iph.daddr == 0) in ipip6_err()
591 if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED) in ipip6_err()
594 if (time_before(jiffies, t->err_time + IPTUNNEL_ERR_TIMEO)) in ipip6_err()
595 t->err_count++; in ipip6_err()
597 t->err_count = 1; in ipip6_err()
598 t->err_time = jiffies; in ipip6_err()
1138 static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p, in ipip6_tunnel_update() argument
1141 struct net *net = t->net; in ipip6_tunnel_update()
1144 ipip6_tunnel_unlink(sitn, t); in ipip6_tunnel_update()
1146 t->parms.iph.saddr = p->iph.saddr; in ipip6_tunnel_update()
1147 t->parms.iph.daddr = p->iph.daddr; in ipip6_tunnel_update()
1148 __dev_addr_set(t->dev, &p->iph.saddr, 4); in ipip6_tunnel_update()
1149 memcpy(t->dev->broadcast, &p->iph.daddr, 4); in ipip6_tunnel_update()
1150 ipip6_tunnel_link(sitn, t); in ipip6_tunnel_update()
1151 t->parms.iph.ttl = p->iph.ttl; in ipip6_tunnel_update()
1152 t->parms.iph.tos = p->iph.tos; in ipip6_tunnel_update()
1153 t->parms.iph.frag_off = p->iph.frag_off; in ipip6_tunnel_update()
1154 if (t->parms.link != p->link || t->fwmark != fwmark) { in ipip6_tunnel_update()
1155 t->parms.link = p->link; in ipip6_tunnel_update()
1156 t->fwmark = fwmark; in ipip6_tunnel_update()
1157 ipip6_tunnel_bind_dev(t->dev); in ipip6_tunnel_update()
1159 dst_cache_reset(&t->dst_cache); in ipip6_tunnel_update()
1160 netdev_state_change(t->dev); in ipip6_tunnel_update()
1164 static int ipip6_tunnel_update_6rd(struct ip_tunnel *t, in ipip6_tunnel_update_6rd() argument
1186 t->ip6rd.prefix = prefix; in ipip6_tunnel_update_6rd()
1187 t->ip6rd.relay_prefix = relay_prefix; in ipip6_tunnel_update_6rd()
1188 t->ip6rd.prefixlen = ip6rd->prefixlen; in ipip6_tunnel_update_6rd()
1189 t->ip6rd.relay_prefixlen = ip6rd->relay_prefixlen; in ipip6_tunnel_update_6rd()
1190 dst_cache_reset(&t->dst_cache); in ipip6_tunnel_update_6rd()
1191 netdev_state_change(t->dev); in ipip6_tunnel_update_6rd()
1198 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_get6rd() local
1205 t = ipip6_tunnel_locate(t->net, &p, 0); in ipip6_tunnel_get6rd()
1207 if (!t) in ipip6_tunnel_get6rd()
1208 t = netdev_priv(dev); in ipip6_tunnel_get6rd()
1210 ip6rd.prefix = t->ip6rd.prefix; in ipip6_tunnel_get6rd()
1211 ip6rd.relay_prefix = t->ip6rd.relay_prefix; in ipip6_tunnel_get6rd()
1212 ip6rd.prefixlen = t->ip6rd.prefixlen; in ipip6_tunnel_get6rd()
1213 ip6rd.relay_prefixlen = t->ip6rd.relay_prefixlen; in ipip6_tunnel_get6rd()
1223 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_6rdctl() local
1227 if (!ns_capable(t->net->user_ns, CAP_NET_ADMIN)) in ipip6_tunnel_6rdctl()
1233 err = ipip6_tunnel_update_6rd(t, &ip6rd); in ipip6_tunnel_6rdctl()
1273 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_get() local
1276 t = ipip6_tunnel_locate(t->net, p, 0); in ipip6_tunnel_get()
1277 if (!t) in ipip6_tunnel_get()
1278 t = netdev_priv(dev); in ipip6_tunnel_get()
1279 memcpy(p, &t->parms, sizeof(*p)); in ipip6_tunnel_get()
1286 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_add() local
1289 err = __ipip6_tunnel_ioctl_validate(t->net, p); in ipip6_tunnel_add()
1293 t = ipip6_tunnel_locate(t->net, p, 1); in ipip6_tunnel_add()
1294 if (!t) in ipip6_tunnel_add()
1302 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_change() local
1305 err = __ipip6_tunnel_ioctl_validate(t->net, p); in ipip6_tunnel_change()
1309 t = ipip6_tunnel_locate(t->net, p, 0); in ipip6_tunnel_change()
1311 if (!t) in ipip6_tunnel_change()
1314 if (t) { in ipip6_tunnel_change()
1315 if (t->dev != dev) in ipip6_tunnel_change()
1321 t = netdev_priv(dev); in ipip6_tunnel_change()
1324 ipip6_tunnel_update(t, p, t->fwmark); in ipip6_tunnel_change()
1333 struct ip_tunnel *t = netdev_priv(dev); in ipip6_tunnel_del() local
1335 if (!ns_capable(t->net->user_ns, CAP_NET_ADMIN)) in ipip6_tunnel_del()
1339 t = ipip6_tunnel_locate(t->net, p, 0); in ipip6_tunnel_del()
1340 if (!t) in ipip6_tunnel_del()
1342 if (t == netdev_priv(dev_to_sit_net(dev)->fb_tunnel_dev)) in ipip6_tunnel_del()
1344 dev = t->dev; in ipip6_tunnel_del()
1606 struct ip_tunnel *t = netdev_priv(dev); in ipip6_changelink() local
1609 struct net *net = t->net; in ipip6_changelink()
1614 __u32 fwmark = t->fwmark; in ipip6_changelink()
1621 err = ip_tunnel_encap_setup(t, &ipencap); in ipip6_changelink()
1632 t = ipip6_tunnel_locate(net, &p, 0); in ipip6_changelink()
1634 if (t) { in ipip6_changelink()
1635 if (t->dev != dev) in ipip6_changelink()
1638 t = netdev_priv(dev); in ipip6_changelink()
1640 ipip6_tunnel_update(t, &p, fwmark); in ipip6_changelink()
1644 return ipip6_tunnel_update_6rd(t, &ip6rd); in ipip6_changelink()
1817 struct ip_tunnel *t; in sit_destroy_tunnels() local
1819 t = rtnl_dereference(sitn->tunnels[prio][h]); in sit_destroy_tunnels()
1820 while (t) { in sit_destroy_tunnels()
1824 if (!net_eq(dev_net(t->dev), net)) in sit_destroy_tunnels()
1825 unregister_netdevice_queue(t->dev, in sit_destroy_tunnels()
1827 t = rtnl_dereference(t->next); in sit_destroy_tunnels()
1836 struct ip_tunnel *t; in sit_init_net() local
1868 t = netdev_priv(sitn->fb_tunnel_dev); in sit_init_net()
1870 strcpy(t->parms.name, sitn->fb_tunnel_dev->name); in sit_init_net()