1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, int link, __be16 flags, __be32 remote, __be32 local, __be32 key) { unsigned int hash; struct ip_tunnel *t, *cand = NULL; struct hlist_head *head;
pr_info("ip_tunnel_lookup\n");
hash = ip_tunnel_hash(key, remote); pr_info("ip_tunnel_hash(%d, %d)-1>hash:%d\n", key, remote, hash);
head = &itn->tunnels[hash]; pr_info("1head:%lu\n", (long unsigned int)head);
hlist_for_each_entry_rcu(t, head, hash_node) { pr_info("1local%d, saddr%d, remote%d, daddr%d, flags%x, IFF_UP%x\n", local, t->parms.iph.saddr, remote, t->parms.iph.daddr, t->dev->flags, IFF_UP); if (local != t->parms.iph.saddr || remote != t->parms.iph.daddr || !(t->dev->flags & IFF_UP)){ pr_info("local%d != t->parms.iph.saddr%d || remote%d != t->parms.iph.daddr%d || !(t->dev->flags%x & IFF_UP%x) continue\n", local, t->parms.iph.saddr, remote, t->parms.iph.daddr, t->dev->flags, IFF_UP); continue; }
if (!ip_tunnel_key_match(&t->parms, flags, key)){ pr_info("!ip_tunnel_key_match(&t->parms, %x, %d) continue\n", flags, key); continue; }
if (t->parms.link == link){ pr_info("t->parms.link%d == link%d return t\n", t->parms.link, link); return t; } else{ pr_info("t->parms.link%d != link%d cand=t\n", t->parms.link, link); cand = t; } }
hlist_for_each_entry_rcu(t, head, hash_node) { pr_info("remote:%d, daddr:%d, saddr:%d, flags%x&%x:%d\n", remote, t->parms.iph.daddr, t->parms.iph.saddr, t->dev->flags, IFF_UP, (t->dev->flags & IFF_UP)); if (remote != t->parms.iph.daddr || t->parms.iph.saddr != 0 || !(t->dev->flags & IFF_UP)){ pr_info("remote%d != t->parms.iph.daddr%d || t->parms.iph.saddr%d != 0 || !(t->dev->flags%x & IFF_UP%x) continue\n", remote, t->parms.iph.daddr, t->parms.iph.saddr, t->dev->flags, IFF_UP); continue; }
if (!ip_tunnel_key_match(&t->parms, flags, key)){ pr_info("!ip_tunnel_key_match(&t->parms, %x, %d) continue\n", flags, key); continue; }
if (t->parms.link == link){ pr_info("t->parms.link%d == link%d return t\n", t->parms.link, link); return t; } else if (!cand){ pr_info("t->parms.link%d != link%d cand=t\n", t->parms.link, link); cand = t; } }
hash = ip_tunnel_hash(key, 0); pr_info("ip_tunnel_hash(%d, 0)-2>hash:%d\n", remote, hash); head = &itn->tunnels[hash]; pr_info("2head:%lu\n", (long unsigned int)head);
hlist_for_each_entry_rcu(t, head, hash_node) { pr_info("local:%d, saddr:%d, daddr:%d\n", local, t->parms.iph.saddr, t->parms.iph.daddr); if ((local != t->parms.iph.saddr || t->parms.iph.daddr != 0) && (local != t->parms.iph.daddr || !ipv4_is_multicast(local))){ pr_info("(local%d != t->parms.iph.saddr%d || t->parms.iph.daddr%d != 0) && (local%d != t->parms.iph.daddr%d || !ipv4_is_multicast(local)) continue\n", local, t->parms.iph.saddr, t->parms.iph.daddr, local, t->parms.iph.daddr); continue; }
if (!(t->dev->flags & IFF_UP)){ pr_info("!(t->dev->flags%x & IFF_UP%x) continue\n", t->dev->flags, IFF_UP); continue; }
if (!ip_tunnel_key_match(&t->parms, flags, key)){ pr_info("!ip_tunnel_key_match(&t->parms, %x, %d) continue\n", flags, key); continue; }
if (t->parms.link == link){ pr_info("t->parms.link%d == link%d return t\n", t->parms.link, link); return t; } else if (!cand){ pr_info("t->parms.link%d != link%d cand=t\n", t->parms.link, link); cand = t; } }
if (flags & TUNNEL_NO_KEY){ pr_info("flags%x & TUNNEL_NO_KEY%x goto skip_key_lookup\n", flags, TUNNEL_NO_KEY); goto skip_key_lookup; }
hlist_for_each_entry_rcu(t, head, hash_node) { if (t->parms.i_key != key || t->parms.iph.saddr != 0 || t->parms.iph.daddr != 0 || !(t->dev->flags & IFF_UP)){ pr_info("t->parms.i_key%d != key%d || t->parms.iph.saddr%d != 0 || t->parms.iph.daddr%d != 0 || !(t->dev->flags%x & IFF_UP%x) continue\n", t->parms.i_key, key, t->parms.iph.saddr, t->parms.iph.daddr, t->dev->flags, IFF_UP); continue; }
if (t->parms.link == link){ pr_info("t->parms.link%d == link%d return t\n", t->parms.link, link); return t; } else if (!cand){ pr_info("t->parms.link%d != link%d cand=t\n", t->parms.link, link); cand = t; } }
skip_key_lookup: if (cand){ pr_info("cand not NULL return cand\n"); return cand; }
t = rcu_dereference(itn->collect_md_tun); pr_info("t = rcu_dereference(itn->collect_md_tun)\n"); if (t){ pr_info("t not NULL return t\n"); return t; }
if (itn->fb_tunnel_dev && itn->fb_tunnel_dev->flags & IFF_UP){ pr_info("itn->fb_tunnel_dev && itn->fb_tunnel_dev->flags & IFF_UP return netdev_priv(itn->fb_tunnel_dev);\n"); return netdev_priv(itn->fb_tunnel_dev); }
return NULL; } EXPORT_SYMBOL_GPL(ip_tunnel_lookup);
|