Lines Matching refs:fdb

69 				  const struct net_bridge_fdb_entry *fdb)  in has_expired()  argument
71 return !test_bit(BR_FDB_STATIC, &fdb->flags) && in has_expired()
72 !test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags) && in has_expired()
73 time_before_eq(fdb->updated + hold_time(br), jiffies); in has_expired()
84 const struct net_bridge_fdb_entry *fdb) in fdb_to_nud() argument
86 if (test_bit(BR_FDB_LOCAL, &fdb->flags)) in fdb_to_nud()
88 else if (test_bit(BR_FDB_STATIC, &fdb->flags)) in fdb_to_nud()
90 else if (has_expired(br, fdb)) in fdb_to_nud()
97 const struct net_bridge_fdb_entry *fdb, in fdb_fill_info() argument
100 const struct net_bridge_port *dst = READ_ONCE(fdb->dst); in fdb_fill_info()
118 ndm->ndm_state = fdb_to_nud(br, fdb); in fdb_fill_info()
120 if (test_bit(BR_FDB_OFFLOADED, &fdb->flags)) in fdb_fill_info()
122 if (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) in fdb_fill_info()
124 if (test_bit(BR_FDB_STICKY, &fdb->flags)) in fdb_fill_info()
126 if (test_bit(BR_FDB_LOCKED, &fdb->flags)) in fdb_fill_info()
129 if (nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->key.addr)) in fdb_fill_info()
136 ci.ndm_used = jiffies_to_clock_t(now - fdb->used); in fdb_fill_info()
138 ci.ndm_updated = jiffies_to_clock_t(now - fdb->updated); in fdb_fill_info()
143 if (fdb->key.vlan_id && nla_put(skb, NDA_VLAN, sizeof(u16), in fdb_fill_info()
144 &fdb->key.vlan_id)) in fdb_fill_info()
147 if (test_bit(BR_FDB_NOTIFY, &fdb->flags)) { in fdb_fill_info()
153 if (test_bit(BR_FDB_NOTIFY_INACTIVE, &fdb->flags)) in fdb_fill_info()
185 const struct net_bridge_fdb_entry *fdb, int type, in fdb_notify() argument
193 br_switchdev_fdb_notify(br, fdb, type); in fdb_notify()
199 err = fdb_fill_info(skb, br, fdb, 0, 0, type, 0); in fdb_notify()
231 struct net_bridge_fdb_entry *fdb; in br_fdb_find() local
236 fdb = fdb_find_rcu(&br->fdb_hash_tbl, addr, vid); in br_fdb_find()
239 return fdb; in br_fdb_find()
398 struct net_bridge_fdb_entry *fdb; in fdb_create() local
409 fdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC); in fdb_create()
410 if (!fdb) in fdb_create()
413 memcpy(fdb->key.addr.addr, addr, ETH_ALEN); in fdb_create()
414 WRITE_ONCE(fdb->dst, source); in fdb_create()
415 fdb->key.vlan_id = vid; in fdb_create()
416 fdb->flags = flags; in fdb_create()
417 fdb->updated = fdb->used = jiffies; in fdb_create()
418 err = rhashtable_lookup_insert_fast(&br->fdb_hash_tbl, &fdb->rhnode, in fdb_create()
421 kmem_cache_free(br_fdb_cache, fdb); in fdb_create()
428 hlist_add_head_rcu(&fdb->fdb_node, &br->fdb_list); in fdb_create()
430 return fdb; in fdb_create()
436 struct net_bridge_fdb_entry *fdb; in fdb_add_local() local
441 fdb = br_fdb_find(br, addr, vid); in fdb_add_local()
442 if (fdb) { in fdb_add_local()
446 if (test_bit(BR_FDB_LOCAL, &fdb->flags)) in fdb_add_local()
450 fdb_delete(br, fdb, true); in fdb_add_local()
453 fdb = fdb_create(br, source, addr, vid, in fdb_add_local()
455 if (!fdb) in fdb_add_local()
459 fdb_notify(br, fdb, RTM_NEWNEIGH, true); in fdb_add_local()
799 struct net_bridge_fdb_entry *fdb; in br_fdb_test_addr() local
810 fdb = br_fdb_find_rcu(port->br, addr, 0); in br_fdb_test_addr()
811 if (fdb) in br_fdb_test_addr()
812 dst = READ_ONCE(fdb->dst); in br_fdb_test_addr()
884 static bool __fdb_mark_active(struct net_bridge_fdb_entry *fdb) in __fdb_mark_active() argument
886 return !!(test_bit(BR_FDB_NOTIFY_INACTIVE, &fdb->flags) && in __fdb_mark_active()
887 test_and_clear_bit(BR_FDB_NOTIFY_INACTIVE, &fdb->flags)); in __fdb_mark_active()
893 struct net_bridge_fdb_entry *fdb; in br_fdb_update() local
899 fdb = fdb_find_rcu(&br->fdb_hash_tbl, addr, vid); in br_fdb_update()
900 if (likely(fdb)) { in br_fdb_update()
902 if (unlikely(test_bit(BR_FDB_LOCAL, &fdb->flags))) { in br_fdb_update()
910 if (now != fdb->updated) { in br_fdb_update()
911 fdb->updated = now; in br_fdb_update()
912 fdb_modified = __fdb_mark_active(fdb); in br_fdb_update()
916 if (unlikely(source != READ_ONCE(fdb->dst) && in br_fdb_update()
917 !test_bit(BR_FDB_STICKY, &fdb->flags))) { in br_fdb_update()
918 br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); in br_fdb_update()
919 WRITE_ONCE(fdb->dst, source); in br_fdb_update()
923 &fdb->flags))) in br_fdb_update()
925 &fdb->flags); in br_fdb_update()
929 if (unlikely(test_bit(BR_FDB_LOCKED, &fdb->flags))) in br_fdb_update()
930 clear_bit(BR_FDB_LOCKED, &fdb->flags); in br_fdb_update()
934 set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags); in br_fdb_update()
936 &fdb->flags)) in br_fdb_update()
941 fdb_notify(br, fdb, RTM_NEWNEIGH, true); in br_fdb_update()
946 fdb = fdb_create(br, source, addr, vid, flags); in br_fdb_update()
947 if (fdb) { in br_fdb_update()
949 fdb_notify(br, fdb, RTM_NEWNEIGH, true); in br_fdb_update()
1038 static bool fdb_handle_notify(struct net_bridge_fdb_entry *fdb, u8 notify) in fdb_handle_notify() argument
1044 !test_and_set_bit(BR_FDB_NOTIFY_INACTIVE, &fdb->flags)) in fdb_handle_notify()
1048 !test_and_set_bit(BR_FDB_NOTIFY, &fdb->flags)) { in fdb_handle_notify()
1052 test_and_clear_bit(BR_FDB_NOTIFY, &fdb->flags)) { in fdb_handle_notify()
1054 clear_bit(BR_FDB_NOTIFY_INACTIVE, &fdb->flags); in fdb_handle_notify()
1068 struct net_bridge_fdb_entry *fdb; in fdb_add_entry() local
1095 fdb = br_fdb_find(br, addr, vid); in fdb_add_entry()
1096 if (fdb == NULL) { in fdb_add_entry()
1100 fdb = fdb_create(br, source, addr, vid, in fdb_add_entry()
1102 if (!fdb) in fdb_add_entry()
1110 if (READ_ONCE(fdb->dst) != source) { in fdb_add_entry()
1111 WRITE_ONCE(fdb->dst, source); in fdb_add_entry()
1115 set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags); in fdb_add_entry()
1116 if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &fdb->flags)) in fdb_add_entry()
1120 if (fdb_to_nud(br, fdb) != state) { in fdb_add_entry()
1122 set_bit(BR_FDB_LOCAL, &fdb->flags); in fdb_add_entry()
1123 if (!test_and_set_bit(BR_FDB_STATIC, &fdb->flags)) in fdb_add_entry()
1126 clear_bit(BR_FDB_LOCAL, &fdb->flags); in fdb_add_entry()
1127 if (!test_and_set_bit(BR_FDB_STATIC, &fdb->flags)) in fdb_add_entry()
1130 clear_bit(BR_FDB_LOCAL, &fdb->flags); in fdb_add_entry()
1131 if (test_and_clear_bit(BR_FDB_STATIC, &fdb->flags)) in fdb_add_entry()
1138 if (is_sticky != test_bit(BR_FDB_STICKY, &fdb->flags)) { in fdb_add_entry()
1139 change_bit(BR_FDB_STICKY, &fdb->flags); in fdb_add_entry()
1143 if (test_and_clear_bit(BR_FDB_LOCKED, &fdb->flags)) in fdb_add_entry()
1146 if (fdb_handle_notify(fdb, notify)) in fdb_add_entry()
1149 fdb->used = jiffies; in fdb_add_entry()
1152 fdb->updated = jiffies; in fdb_add_entry()
1153 fdb_notify(br, fdb, RTM_NEWNEIGH, true); in fdb_add_entry()
1297 struct net_bridge_fdb_entry *fdb; in fdb_delete_by_addr_and_port() local
1299 fdb = br_fdb_find(br, addr, vlan); in fdb_delete_by_addr_and_port()
1300 if (!fdb || READ_ONCE(fdb->dst) != p) in fdb_delete_by_addr_and_port()
1303 fdb_delete(br, fdb, true); in fdb_delete_by_addr_and_port()
1427 struct net_bridge_fdb_entry *fdb; in br_fdb_external_learn_add() local
1438 fdb = br_fdb_find(br, addr, vid); in br_fdb_external_learn_add()
1439 if (!fdb) { in br_fdb_external_learn_add()
1451 fdb = fdb_create(br, p, addr, vid, flags); in br_fdb_external_learn_add()
1452 if (!fdb) { in br_fdb_external_learn_add()
1456 fdb_notify(br, fdb, RTM_NEWNEIGH, swdev_notify); in br_fdb_external_learn_add()
1459 (!test_bit(BR_FDB_LOCKED, &fdb->flags) || in br_fdb_external_learn_add()
1460 READ_ONCE(fdb->dst) != p)) { in br_fdb_external_learn_add()
1465 fdb->updated = jiffies; in br_fdb_external_learn_add()
1467 if (READ_ONCE(fdb->dst) != p) { in br_fdb_external_learn_add()
1468 WRITE_ONCE(fdb->dst, p); in br_fdb_external_learn_add()
1472 if (test_and_set_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) { in br_fdb_external_learn_add()
1474 fdb->used = jiffies; in br_fdb_external_learn_add()
1479 if (locked != test_bit(BR_FDB_LOCKED, &fdb->flags)) { in br_fdb_external_learn_add()
1480 change_bit(BR_FDB_LOCKED, &fdb->flags); in br_fdb_external_learn_add()
1485 set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags); in br_fdb_external_learn_add()
1488 set_bit(BR_FDB_LOCAL, &fdb->flags); in br_fdb_external_learn_add()
1491 test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &fdb->flags)) in br_fdb_external_learn_add()
1495 fdb_notify(br, fdb, RTM_NEWNEIGH, swdev_notify); in br_fdb_external_learn_add()
1508 struct net_bridge_fdb_entry *fdb; in br_fdb_external_learn_del() local
1513 fdb = br_fdb_find(br, addr, vid); in br_fdb_external_learn_del()
1514 if (fdb && test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) in br_fdb_external_learn_del()
1515 fdb_delete(br, fdb, swdev_notify); in br_fdb_external_learn_del()
1527 struct net_bridge_fdb_entry *fdb; in br_fdb_offloaded_set() local
1531 fdb = br_fdb_find(br, addr, vid); in br_fdb_offloaded_set()
1532 if (fdb && offloaded != test_bit(BR_FDB_OFFLOADED, &fdb->flags)) in br_fdb_offloaded_set()
1533 change_bit(BR_FDB_OFFLOADED, &fdb->flags); in br_fdb_offloaded_set()