Lines Matching full:tunnel
121 static u32 amt_source_hash(struct amt_tunnel_list *tunnel, union amt_addr *src) in amt_source_hash() argument
123 u32 hash = jhash(src, sizeof(*src), tunnel->amt->hash_seed); in amt_source_hash()
125 return reciprocal_scale(hash, tunnel->amt->hash_buckets); in amt_source_hash()
182 static struct amt_source_node *amt_lookup_src(struct amt_tunnel_list *tunnel, in amt_lookup_src() argument
187 u32 hash = amt_source_hash(tunnel, src); in amt_lookup_src()
198 static u32 amt_group_hash(struct amt_tunnel_list *tunnel, union amt_addr *group) in amt_group_hash() argument
200 u32 hash = jhash(group, sizeof(*group), tunnel->amt->hash_seed); in amt_group_hash()
202 return reciprocal_scale(hash, tunnel->amt->hash_buckets); in amt_group_hash()
205 static struct amt_group_node *amt_lookup_group(struct amt_tunnel_list *tunnel, in amt_lookup_group() argument
210 u32 hash = amt_group_hash(tunnel, group); in amt_lookup_group()
213 hlist_for_each_entry_rcu(gnode, &tunnel->groups[hash], node) { in amt_lookup_group()
226 struct amt_tunnel_list *tunnel; in amt_destroy_source() local
228 tunnel = gnode->tunnel_list; in amt_destroy_source()
246 tunnel->nr_sources--; in amt_destroy_source()
276 /* tunnel->lock was acquired outside of amt_del_group() in amt_del_group()
294 struct amt_tunnel_list *tunnel; in amt_source_work() local
296 tunnel = gnode->tunnel_list; in amt_source_work()
297 spin_lock_bh(&tunnel->lock); in amt_source_work()
310 spin_unlock_bh(&tunnel->lock); in amt_source_work()
313 static void amt_act_src(struct amt_tunnel_list *tunnel, in amt_act_src() argument
318 struct amt_dev *amt = tunnel->amt; in amt_act_src()
413 struct amt_tunnel_list *tunnel = gnode->tunnel_list; in amt_group_work() local
422 spin_lock_bh(&tunnel->lock); in amt_group_work()
425 spin_unlock_bh(&tunnel->lock); in amt_group_work()
447 spin_unlock_bh(&tunnel->lock); in amt_group_work()
464 struct amt_tunnel_list *tunnel, in amt_add_group() argument
473 if (tunnel->nr_groups >= amt->max_groups) in amt_add_group()
486 gnode->tunnel_list = tunnel; in amt_add_group()
493 hash = amt_group_hash(tunnel, group); in amt_add_group()
494 hlist_add_head_rcu(&gnode->node, &tunnel->groups[hash]); in amt_add_group()
495 tunnel->nr_groups++; in amt_add_group()
590 static void __amt_update_relay_status(struct amt_tunnel_list *tunnel, in __amt_update_relay_status() argument
594 if (validate && tunnel->status >= status) in __amt_update_relay_status()
596 netdev_dbg(tunnel->amt->dev, in __amt_update_relay_status()
597 "Update Tunnel(IP = %pI4, PORT = %u) status %s -> %s", in __amt_update_relay_status()
598 &tunnel->ip4, ntohs(tunnel->source_port), in __amt_update_relay_status()
599 status_str[tunnel->status], status_str[status]); in __amt_update_relay_status()
600 tunnel->status = status; in __amt_update_relay_status()
603 static void amt_update_relay_status(struct amt_tunnel_list *tunnel, in amt_update_relay_status() argument
606 spin_lock_bh(&tunnel->lock); in amt_update_relay_status()
607 __amt_update_relay_status(tunnel, status, validate); in amt_update_relay_status()
608 spin_unlock_bh(&tunnel->lock); in amt_update_relay_status()
791 struct amt_tunnel_list *tunnel) in amt_send_igmp_gq() argument
799 amt_skb_cb(skb)->tunnel = tunnel; in amt_send_igmp_gq()
876 static void amt_send_mld_gq(struct amt_dev *amt, struct amt_tunnel_list *tunnel) in amt_send_mld_gq() argument
884 amt_skb_cb(skb)->tunnel = tunnel; in amt_send_mld_gq()
888 static void amt_send_mld_gq(struct amt_dev *amt, struct amt_tunnel_list *tunnel) in amt_send_mld_gq() argument
1056 struct amt_tunnel_list *tunnel, in amt_send_multicast_data() argument
1078 fl4.daddr = tunnel->ip4; in amt_send_multicast_data()
1083 netdev_dbg(amt->dev, "no route to %pI4\n", &tunnel->ip4); in amt_send_multicast_data()
1104 tunnel->source_port, in amt_send_multicast_data()
1111 struct amt_tunnel_list *tunnel, in amt_send_membership_query() argument
1132 fl4.daddr = tunnel->ip4; in amt_send_membership_query()
1138 netdev_dbg(amt->dev, "no route to %pI4\n", &tunnel->ip4); in amt_send_membership_query()
1148 amtmq->nonce = tunnel->nonce; in amt_send_membership_query()
1149 amtmq->response_mac = tunnel->mac; in amt_send_membership_query()
1162 tunnel->source_port, in amt_send_membership_query()
1165 amt_update_relay_status(tunnel, AMT_STATUS_SENT_QUERY, true); in amt_send_membership_query()
1172 struct amt_tunnel_list *tunnel; in amt_dev_xmit() local
1257 tunnel = amt_skb_cb(skb)->tunnel; in amt_dev_xmit()
1258 if (!tunnel) { in amt_dev_xmit()
1264 if (amt_send_membership_query(amt, skb, tunnel, v6)) in amt_dev_xmit()
1271 list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) { in amt_dev_xmit()
1272 hash = amt_group_hash(tunnel, &group); in amt_dev_xmit()
1273 hlist_for_each_entry_rcu(gnode, &tunnel->groups[hash], in amt_dev_xmit()
1288 amt_send_multicast_data(amt, skb, tunnel, v6); in amt_dev_xmit()
1319 static void amt_clear_groups(struct amt_tunnel_list *tunnel) in amt_clear_groups() argument
1321 struct amt_dev *amt = tunnel->amt; in amt_clear_groups()
1326 spin_lock_bh(&tunnel->lock); in amt_clear_groups()
1329 hlist_for_each_entry_safe(gnode, t, &tunnel->groups[i], node) in amt_clear_groups()
1332 spin_unlock_bh(&tunnel->lock); in amt_clear_groups()
1337 struct amt_tunnel_list *tunnel = container_of(to_delayed_work(work), in amt_tunnel_expire() local
1340 struct amt_dev *amt = tunnel->amt; in amt_tunnel_expire()
1344 list_del_rcu(&tunnel->list); in amt_tunnel_expire()
1346 amt_clear_groups(tunnel); in amt_tunnel_expire()
1349 kfree_rcu(tunnel, rcu); in amt_tunnel_expire()
1353 struct amt_tunnel_list *tunnel, in amt_cleanup_srcs() argument
1388 static void amt_add_srcs(struct amt_dev *amt, struct amt_tunnel_list *tunnel, in amt_add_srcs() argument
1414 if (tunnel->nr_sources >= amt->max_sources) in amt_add_srcs()
1423 if (amt_lookup_src(tunnel, gnode, AMT_FILTER_ALL, &src)) in amt_add_srcs()
1428 hash = amt_source_hash(tunnel, &snode->source_addr); in amt_add_srcs()
1430 tunnel->nr_sources++; in amt_add_srcs()
1468 static void amt_lookup_act_srcs(struct amt_tunnel_list *tunnel, in amt_lookup_act_srcs() argument
1476 struct amt_dev *amt = tunnel->amt; in amt_lookup_act_srcs()
1511 snode = amt_lookup_src(tunnel, gnode, filter, &src); in amt_lookup_act_srcs()
1514 amt_act_src(tunnel, gnode, snode, act); in amt_lookup_act_srcs()
1523 amt_act_src(tunnel, gnode, snode, act); in amt_lookup_act_srcs()
1534 snode = amt_lookup_src(tunnel, gnode, filter, &src); in amt_lookup_act_srcs()
1537 amt_act_src(tunnel, gnode, snode, act); in amt_lookup_act_srcs()
1560 amt_act_src(tunnel, gnode, snode, act); in amt_lookup_act_srcs()
1576 snode = amt_lookup_src(tunnel, gnode, AMT_FILTER_ALL, in amt_lookup_act_srcs()
1579 snode = amt_lookup_src(tunnel, gnode, in amt_lookup_act_srcs()
1582 amt_act_src(tunnel, gnode, snode, act); in amt_lookup_act_srcs()
1593 struct amt_tunnel_list *tunnel, in amt_mcast_is_in_handler() argument
1603 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_is_in_handler()
1608 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_is_in_handler()
1613 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_is_in_handler()
1623 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_is_in_handler()
1628 amt_lookup_act_srcs(tunnel, gnode, zero_grec, AMT_OPS_UNI, in amt_mcast_is_in_handler()
1633 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_is_in_handler()
1638 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB, in amt_mcast_is_in_handler()
1646 struct amt_tunnel_list *tunnel, in amt_mcast_is_ex_handler() argument
1658 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_is_ex_handler()
1663 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB_REV, in amt_mcast_is_ex_handler()
1668 amt_lookup_act_srcs(tunnel, gnode, zero_grec, AMT_OPS_UNI, in amt_mcast_is_ex_handler()
1687 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB_REV, in amt_mcast_is_ex_handler()
1692 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_is_ex_handler()
1697 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB_REV, in amt_mcast_is_ex_handler()
1710 struct amt_tunnel_list *tunnel, in amt_mcast_to_in_handler() argument
1721 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_to_in_handler()
1726 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_to_in_handler()
1731 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_to_in_handler()
1743 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_to_in_handler()
1748 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_to_in_handler()
1756 amt_lookup_act_srcs(tunnel, gnode, zero_grec, AMT_OPS_UNI, in amt_mcast_to_in_handler()
1763 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_to_in_handler()
1771 struct amt_tunnel_list *tunnel, in amt_mcast_to_ex_handler() argument
1784 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_to_ex_handler()
1789 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB_REV, in amt_mcast_to_ex_handler()
1794 amt_lookup_act_srcs(tunnel, gnode, zero_grec, AMT_OPS_UNI, in amt_mcast_to_ex_handler()
1814 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB_REV, in amt_mcast_to_ex_handler()
1819 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB_REV, in amt_mcast_to_ex_handler()
1824 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_to_ex_handler()
1837 struct amt_tunnel_list *tunnel, in amt_mcast_allow_handler() argument
1847 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_allow_handler()
1852 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_allow_handler()
1862 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_allow_handler()
1867 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB, in amt_mcast_allow_handler()
1874 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT, in amt_mcast_allow_handler()
1882 struct amt_tunnel_list *tunnel, in amt_mcast_block_handler() argument
1892 amt_lookup_act_srcs(tunnel, gnode, zero_grec, AMT_OPS_UNI, in amt_mcast_block_handler()
1903 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB_REV, in amt_mcast_block_handler()
1908 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_block_handler()
1913 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_SUB_REV, in amt_mcast_block_handler()
1918 amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI, in amt_mcast_block_handler()
1938 struct amt_tunnel_list *tunnel) in amt_igmpv2_report_handler() argument
1950 gnode = amt_lookup_group(tunnel, &group, &host, false); in amt_igmpv2_report_handler()
1952 gnode = amt_add_group(amt, tunnel, &group, &host, false); in amt_igmpv2_report_handler()
1975 struct amt_tunnel_list *tunnel) in amt_igmpv2_leave_handler() argument
1987 gnode = amt_lookup_group(tunnel, &group, &host, false); in amt_igmpv2_leave_handler()
1993 struct amt_tunnel_list *tunnel) in amt_igmpv3_report_handler() argument
2021 gnode = amt_lookup_group(tunnel, &group, &host, false); in amt_igmpv3_report_handler()
2023 gnode = amt_add_group(amt, tunnel, &group, &host, in amt_igmpv3_report_handler()
2029 amt_add_srcs(amt, tunnel, gnode, grec, false); in amt_igmpv3_report_handler()
2032 amt_mcast_is_in_handler(amt, tunnel, gnode, grec, in amt_igmpv3_report_handler()
2036 amt_mcast_is_ex_handler(amt, tunnel, gnode, grec, in amt_igmpv3_report_handler()
2040 amt_mcast_to_in_handler(amt, tunnel, gnode, grec, in amt_igmpv3_report_handler()
2044 amt_mcast_to_ex_handler(amt, tunnel, gnode, grec, in amt_igmpv3_report_handler()
2048 amt_mcast_allow_handler(amt, tunnel, gnode, grec, in amt_igmpv3_report_handler()
2052 amt_mcast_block_handler(amt, tunnel, gnode, grec, in amt_igmpv3_report_handler()
2058 amt_cleanup_srcs(amt, tunnel, gnode); in amt_igmpv3_report_handler()
2062 /* caller held tunnel->lock */
2064 struct amt_tunnel_list *tunnel) in amt_igmp_report_handler() argument
2070 amt_igmpv3_report_handler(amt, skb, tunnel); in amt_igmp_report_handler()
2073 amt_igmpv2_report_handler(amt, skb, tunnel); in amt_igmp_report_handler()
2076 amt_igmpv2_leave_handler(amt, skb, tunnel); in amt_igmp_report_handler()
2099 struct amt_tunnel_list *tunnel) in amt_mldv1_report_handler() argument
2109 gnode = amt_lookup_group(tunnel, &group, &host, true); in amt_mldv1_report_handler()
2111 gnode = amt_add_group(amt, tunnel, &group, &host, true); in amt_mldv1_report_handler()
2136 struct amt_tunnel_list *tunnel) in amt_mldv1_leave_handler() argument
2147 gnode = amt_lookup_group(tunnel, &group, &host, true); in amt_mldv1_leave_handler()
2155 struct amt_tunnel_list *tunnel) in amt_mldv2_report_handler() argument
2183 gnode = amt_lookup_group(tunnel, &group, &host, true); in amt_mldv2_report_handler()
2185 gnode = amt_add_group(amt, tunnel, &group, &host, in amt_mldv2_report_handler()
2191 amt_add_srcs(amt, tunnel, gnode, grec, true); in amt_mldv2_report_handler()
2194 amt_mcast_is_in_handler(amt, tunnel, gnode, grec, in amt_mldv2_report_handler()
2198 amt_mcast_is_ex_handler(amt, tunnel, gnode, grec, in amt_mldv2_report_handler()
2202 amt_mcast_to_in_handler(amt, tunnel, gnode, grec, in amt_mldv2_report_handler()
2206 amt_mcast_to_ex_handler(amt, tunnel, gnode, grec, in amt_mldv2_report_handler()
2210 amt_mcast_allow_handler(amt, tunnel, gnode, grec, in amt_mldv2_report_handler()
2214 amt_mcast_block_handler(amt, tunnel, gnode, grec, in amt_mldv2_report_handler()
2220 amt_cleanup_srcs(amt, tunnel, gnode); in amt_mldv2_report_handler()
2224 /* caller held tunnel->lock */
2226 struct amt_tunnel_list *tunnel) in amt_mld_report_handler() argument
2232 amt_mldv1_report_handler(amt, skb, tunnel); in amt_mld_report_handler()
2235 amt_mldv2_report_handler(amt, skb, tunnel); in amt_mld_report_handler()
2238 amt_mldv1_leave_handler(amt, skb, tunnel); in amt_mld_report_handler()
2449 struct amt_tunnel_list *tunnel; in amt_update_handler() local
2469 list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) { in amt_update_handler()
2470 if (tunnel->ip4 == iph->saddr) { in amt_update_handler()
2471 if ((amtmu->nonce == tunnel->nonce && in amt_update_handler()
2472 amtmu->response_mac == tunnel->mac)) { in amt_update_handler()
2473 mod_delayed_work(amt_wq, &tunnel->gc_wq, in amt_update_handler()
2497 spin_lock_bh(&tunnel->lock); in amt_update_handler()
2498 amt_igmp_report_handler(amt, skb, tunnel); in amt_update_handler()
2499 spin_unlock_bh(&tunnel->lock); in amt_update_handler()
2516 spin_lock_bh(&tunnel->lock); in amt_update_handler()
2517 amt_mld_report_handler(amt, skb, tunnel); in amt_update_handler()
2518 spin_unlock_bh(&tunnel->lock); in amt_update_handler()
2537 amt_update_relay_status(tunnel, AMT_STATUS_RECEIVED_UPDATE, in amt_update_handler()
2661 struct amt_tunnel_list *tunnel; in amt_request_handler() local
2678 list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) in amt_request_handler()
2679 if (tunnel->ip4 == iph->saddr) in amt_request_handler()
2689 tunnel = kzalloc(sizeof(*tunnel) + in amt_request_handler()
2692 if (!tunnel) { in amt_request_handler()
2697 tunnel->source_port = udph->source; in amt_request_handler()
2698 tunnel->ip4 = iph->saddr; in amt_request_handler()
2700 memcpy(&key, &tunnel->key, sizeof(unsigned long long)); in amt_request_handler()
2701 tunnel->amt = amt; in amt_request_handler()
2702 spin_lock_init(&tunnel->lock); in amt_request_handler()
2704 INIT_HLIST_HEAD(&tunnel->groups[i]); in amt_request_handler()
2706 INIT_DELAYED_WORK(&tunnel->gc_wq, amt_tunnel_expire); in amt_request_handler()
2708 list_add_tail_rcu(&tunnel->list, &amt->tunnel_list); in amt_request_handler()
2709 tunnel->key = amt->key; in amt_request_handler()
2710 __amt_update_relay_status(tunnel, AMT_STATUS_RECEIVED_REQUEST, true); in amt_request_handler()
2712 mod_delayed_work(amt_wq, &tunnel->gc_wq, in amt_request_handler()
2717 tunnel->nonce = amtrh->nonce; in amt_request_handler()
2718 mac = siphash_3u32((__force u32)tunnel->ip4, in amt_request_handler()
2719 (__force u32)tunnel->source_port, in amt_request_handler()
2720 (__force u32)tunnel->nonce, in amt_request_handler()
2721 &tunnel->key); in amt_request_handler()
2722 tunnel->mac = mac >> 16; in amt_request_handler()
2728 amt_send_igmp_gq(amt, tunnel); in amt_request_handler()
2730 amt_send_mld_gq(amt, tunnel); in amt_request_handler()
3016 struct amt_tunnel_list *tunnel, *tmp; in amt_dev_stop() local
3045 list_for_each_entry_safe(tunnel, tmp, &amt->tunnel_list, list) { in amt_dev_stop()
3046 list_del_rcu(&tunnel->list); in amt_dev_stop()
3048 cancel_delayed_work_sync(&tunnel->gc_wq); in amt_dev_stop()
3049 amt_clear_groups(tunnel); in amt_dev_stop()
3050 kfree_rcu(tunnel, rcu); in amt_dev_stop()