Lines Matching defs:t
79 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
80 static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu);
81 static void ip6erspan_tnl_link_config(struct ip6_tnl *t, int set_mtu);
114 static bool ip6gre_tunnel_match(struct ip6_tnl *t, int dev_type, int link,
119 if (t->dev->type != ARPHRD_IP6GRE &&
120 t->dev->type != dev_type)
123 if (t->parms.link != link)
125 if (t->dev->type != dev_type)
128 *ret = t;
133 *ret = t;
148 struct ip6_tnl *t, *cand = NULL;
157 for_each_ip_tunnel_rcu(t, ign->tunnels_r_l[h0 ^ h1]) {
158 if (!ipv6_addr_equal(local, &t->parms.laddr) ||
159 !ipv6_addr_equal(remote, &t->parms.raddr) ||
160 key != t->parms.i_key ||
161 !(t->dev->flags & IFF_UP))
164 if (ip6gre_tunnel_match(t, dev_type, link, &cand_score, &cand))
168 for_each_ip_tunnel_rcu(t, ign->tunnels_r[h0 ^ h1]) {
169 if (!ipv6_addr_equal(remote, &t->parms.raddr) ||
170 key != t->parms.i_key ||
171 !(t->dev->flags & IFF_UP))
174 if (ip6gre_tunnel_match(t, dev_type, link, &cand_score, &cand))
178 for_each_ip_tunnel_rcu(t, ign->tunnels_l[h1]) {
179 if ((!ipv6_addr_equal(local, &t->parms.laddr) &&
180 (!ipv6_addr_equal(local, &t->parms.raddr) ||
182 key != t->parms.i_key ||
183 !(t->dev->flags & IFF_UP))
186 if (ip6gre_tunnel_match(t, dev_type, link, &cand_score, &cand))
190 for_each_ip_tunnel_rcu(t, ign->tunnels_wc[h1]) {
191 if (t->parms.i_key != key ||
192 !(t->dev->flags & IFF_UP))
195 if (ip6gre_tunnel_match(t, dev_type, link, &cand_score, &cand))
204 t = rcu_dereference(ign->collect_md_tun_erspan);
206 t = rcu_dereference(ign->collect_md_tun);
208 if (t && t->dev->flags & IFF_UP)
209 return t;
236 static void ip6gre_tunnel_link_md(struct ip6gre_net *ign, struct ip6_tnl *t)
238 if (t->parms.collect_md)
239 rcu_assign_pointer(ign->collect_md_tun, t);
242 static void ip6erspan_tunnel_link_md(struct ip6gre_net *ign, struct ip6_tnl *t)
244 if (t->parms.collect_md)
245 rcu_assign_pointer(ign->collect_md_tun_erspan, t);
248 static void ip6gre_tunnel_unlink_md(struct ip6gre_net *ign, struct ip6_tnl *t)
250 if (t->parms.collect_md)
255 struct ip6_tnl *t)
257 if (t->parms.collect_md)
262 const struct ip6_tnl *t)
264 return __ip6gre_bucket(ign, &t->parms);
267 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t)
269 struct ip6_tnl __rcu **tp = ip6gre_bucket(ign, t);
271 rcu_assign_pointer(t->next, rtnl_dereference(*tp));
272 rcu_assign_pointer(*tp, t);
275 static void ip6gre_tunnel_unlink(struct ip6gre_net *ign, struct ip6_tnl *t)
280 for (tp = ip6gre_bucket(ign, t);
283 if (t == iter) {
284 rcu_assign_pointer(*tp, t->next);
298 struct ip6_tnl *t;
303 (t = rtnl_dereference(*tp)) != NULL;
304 tp = &t->next)
305 if (ipv6_addr_equal(local, &t->parms.laddr) &&
306 ipv6_addr_equal(remote, &t->parms.raddr) &&
307 key == t->parms.i_key &&
308 link == t->parms.link &&
309 type == t->dev->type)
312 return t;
318 struct ip6_tnl *t, *nt;
323 t = ip6gre_tunnel_find(net, parms, ARPHRD_IP6GRE);
324 if (t && create)
326 if (t || !create)
327 return t;
336 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
364 struct ip6_tnl *t = netdev_priv(dev);
365 struct ip6gre_net *ign = net_generic(t->net, ip6gre_net_id);
367 ip6erspan_tunnel_unlink_md(ign, t);
368 ip6gre_tunnel_unlink(ign, t);
369 dst_cache_reset(&t->dst_cache);
370 netdev_put(dev, &t->dev_tracker);
375 struct ip6_tnl *t = netdev_priv(dev);
376 struct ip6gre_net *ign = net_generic(t->net, ip6gre_net_id);
378 ip6gre_tunnel_unlink_md(ign, t);
379 ip6gre_tunnel_unlink(ign, t);
382 dst_cache_reset(&t->dst_cache);
383 netdev_put(dev, &t->dev_tracker);
393 struct ip6_tnl *t;
400 t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
402 if (!t)
408 t->parms.name);
415 t->parms.name);
431 t->parms.name);
435 t->parms.name);
448 if (time_before(jiffies, t->err_time + IP6TUNNEL_ERR_TIMEO))
449 t->err_count++;
451 t->err_count = 1;
452 t->err_time = jiffies;
610 struct ip6_tnl *t = netdev_priv(dev);
612 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
613 *encap_limit = t->parms.encap_limit;
615 memcpy(fl6, &t->fl.u.ip6, sizeof(*fl6));
617 if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
620 *dsfield = ip6_tclass(t->parms.flowinfo);
622 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
625 fl6->flowi6_mark = t->parms.fwmark;
636 struct ip6_tnl *t = netdev_priv(dev);
653 } else if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) {
654 *encap_limit = t->parms.encap_limit;
657 memcpy(fl6, &t->fl.u.ip6, sizeof(*fl6));
659 if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
662 *dsfield = ip6_tclass(t->parms.flowinfo);
664 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
667 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
670 fl6->flowi6_mark = t->parms.fwmark;
682 struct ip6_tnl *t = netdev_priv(dev);
684 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
685 *encap_limit = t->parms.encap_limit;
687 memcpy(fl6, &t->fl.u.ip6, sizeof(*fl6));
689 if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
692 *dsfield = ip6_tclass(t->parms.flowinfo);
694 if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
697 fl6->flowi6_mark = t->parms.fwmark;
790 struct ip6_tnl *t = netdev_priv(dev);
799 if (!t->parms.collect_md)
804 t->parms.o_flags));
823 struct ip6_tnl *t = netdev_priv(dev);
831 if (ipv6_addr_equal(&t->parms.raddr, &ipv6h->saddr))
834 if (!t->parms.collect_md &&
839 t->parms.o_flags)))
855 struct ip6_tnl *t = netdev_priv(dev);
862 if (!t->parms.collect_md &&
867 t->parms.o_flags));
878 struct ip6_tnl *t = netdev_priv(dev);
885 if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
907 if (!t->parms.collect_md || !IS_ERR(skb_tunnel_info_txcheck(skb)))
918 struct ip6_tnl *t = netdev_priv(dev);
933 if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
961 if (skb_cow_head(skb, dev->needed_headroom ?: t->hlen))
964 __clear_bit(IP_TUNNEL_KEY_BIT, t->parms.o_flags);
970 if (t->parms.collect_md) {
1021 if (ipv6_addr_equal(&t->parms.raddr, &ipv6_hdr(skb)->saddr))
1028 memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
1032 if (t->parms.erspan_ver == 1) {
1033 erspan_build_header(skb, ntohl(t->parms.o_key),
1034 t->parms.index,
1037 } else if (t->parms.erspan_ver == 2) {
1038 erspan_build_header_v2(skb, ntohl(t->parms.o_key),
1039 t->parms.dir,
1040 t->parms.hwid,
1047 fl6.daddr = t->parms.raddr;
1053 htonl(atomic_fetch_inc(&t->o_seqno)));
1056 if (!t->parms.collect_md && dst) {
1085 static void ip6gre_tnl_link_config_common(struct ip6_tnl *t)
1087 struct net_device *dev = t->dev;
1088 struct __ip6_tnl_parm *p = &t->parms;
1089 struct flowi6 *fl6 = &t->fl.u.ip6;
1102 fl6->fl6_gre_key = t->parms.o_key;
1110 p->flags |= ip6_tnl_get_cap(t, &p->laddr, &p->raddr);
1119 static void ip6gre_tnl_link_config_route(struct ip6_tnl *t, int set_mtu,
1122 const struct __ip6_tnl_parm *p = &t->parms;
1123 struct net_device *dev = t->dev;
1129 struct rt6_info *rt = rt6_lookup(t->net,
1140 if (t->dev->header_ops)
1148 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
1179 static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
1181 ip6gre_tnl_link_config_common(t);
1182 ip6gre_tnl_link_config_route(t, set_mtu, ip6gre_calc_hlen(t));
1185 static void ip6gre_tnl_copy_tnl_parm(struct ip6_tnl *t,
1188 t->parms.laddr = p->laddr;
1189 t->parms.raddr = p->raddr;
1190 t->parms.flags = p->flags;
1191 t->parms.hop_limit = p->hop_limit;
1192 t->parms.encap_limit = p->encap_limit;
1193 t->parms.flowinfo = p->flowinfo;
1194 t->parms.link = p->link;
1195 t->parms.proto = p->proto;
1196 t->parms.i_key = p->i_key;
1197 t->parms.o_key = p->o_key;
1198 ip_tunnel_flags_copy(t->parms.i_flags, p->i_flags);
1199 ip_tunnel_flags_copy(t->parms.o_flags, p->o_flags);
1200 t->parms.fwmark = p->fwmark;
1201 t->parms.erspan_ver = p->erspan_ver;
1202 t->parms.index = p->index;
1203 t->parms.dir = p->dir;
1204 t->parms.hwid = p->hwid;
1205 dst_cache_reset(&t->dst_cache);
1208 static int ip6gre_tnl_change(struct ip6_tnl *t, const struct __ip6_tnl_parm *p,
1211 ip6gre_tnl_copy_tnl_parm(t, p);
1212 ip6gre_tnl_link_config(t, set_mtu);
1258 struct ip6_tnl *t = netdev_priv(dev);
1259 struct net *net = t->net;
1272 t = ip6gre_tunnel_locate(net, &p1, 0);
1273 if (!t)
1274 t = netdev_priv(dev);
1277 ip6gre_tnl_parm_to_user(&p, &t->parms);
1302 t = ip6gre_tunnel_locate(net, &p1, cmd == SIOCADDTUNNEL);
1305 if (t) {
1306 if (t->dev != dev) {
1311 t = netdev_priv(dev);
1313 ip6gre_tunnel_unlink(ign, t);
1315 ip6gre_tnl_change(t, &p1, 1);
1316 ip6gre_tunnel_link(ign, t);
1321 if (t) {
1325 ip6gre_tnl_parm_to_user(&p, &t->parms);
1343 t = ip6gre_tunnel_locate(net, &p1, 0);
1344 if (!t)
1347 if (t == netdev_priv(ign->fb_tunnel_dev))
1349 dev = t->dev;
1367 struct ip6_tnl *t = netdev_priv(dev);
1371 ipv6h = skb_push(skb, t->hlen + sizeof(*ipv6h));
1373 t->fl.u.ip6.flowlabel,
1374 true, &t->fl.u.ip6));
1375 ipv6h->hop_limit = t->parms.hop_limit;
1377 ipv6h->saddr = t->parms.laddr;
1378 ipv6h->daddr = t->parms.raddr;
1381 p[0] = ip_tunnel_flags_to_be16(t->parms.o_flags);
1393 return t->hlen;
1395 return -t->hlen;
1413 struct ip6_tnl *t = netdev_priv(dev);
1415 gro_cells_destroy(&t->gro_cells);
1416 dst_cache_destroy(&t->dst_cache);
1558 struct ip6_tnl *t;
1560 t = rtnl_net_dereference(net, ign->tunnels[prio][h]);
1562 while (t) {
1566 if (!net_eq(dev_net(t->dev), net))
1567 unregister_netdevice_queue(t->dev, head);
1569 t = rtnl_net_dereference(net, t->next);
2003 struct ip6_tnl *t, *nt = netdev_priv(dev);
2020 t = ip6gre_tunnel_locate(net, p_p, 0);
2022 if (t) {
2023 if (t->dev != dev)
2026 t = nt;
2029 return t;
2036 struct ip6_tnl *t = netdev_priv(dev);
2037 struct ip6gre_net *ign = net_generic(t->net, ip6gre_net_id);
2040 t = ip6gre_changelink_common(dev, tb, data, &p, extack);
2041 if (IS_ERR(t))
2042 return PTR_ERR(t);
2044 ip6gre_tunnel_unlink_md(ign, t);
2045 ip6gre_tunnel_unlink(ign, t);
2046 ip6gre_tnl_change(t, &p, !tb[IFLA_MTU]);
2047 ip6gre_tunnel_link_md(ign, t);
2048 ip6gre_tunnel_link(ign, t);
2105 struct ip6_tnl *t = netdev_priv(dev);
2106 struct __ip6_tnl_parm *p = &t->parms;
2146 t->encap.type) ||
2148 t->encap.sport) ||
2150 t->encap.dport) ||
2152 t->encap.flags))
2237 static void ip6erspan_tnl_link_config(struct ip6_tnl *t, int set_mtu)
2239 ip6gre_tnl_link_config_common(t);
2240 ip6gre_tnl_link_config_route(t, set_mtu, ip6erspan_calc_hlen(t));
2243 static int ip6erspan_tnl_change(struct ip6_tnl *t,
2246 ip6gre_tnl_copy_tnl_parm(t, p);
2247 ip6erspan_tnl_link_config(t, set_mtu);
2257 struct ip6_tnl *t;
2259 t = ip6gre_changelink_common(dev, tb, data, &p, extack);
2260 if (IS_ERR(t))
2261 return PTR_ERR(t);
2264 ip6gre_tunnel_unlink_md(ign, t);
2265 ip6gre_tunnel_unlink(ign, t);
2266 ip6erspan_tnl_change(t, &p, !tb[IFLA_MTU]);
2267 ip6erspan_tunnel_link_md(ign, t);
2268 ip6gre_tunnel_link(ign, t);
2331 pr_info("%s: can't add protocol\n", __func__);