]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: bridge: fdb: convert offloaded to use bitops
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Tue, 29 Oct 2019 11:45:58 +0000 (13:45 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Oct 2019 01:12:49 +0000 (18:12 -0700)
Convert the offloaded field to a flag and use bitops.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_fdb.c
net/bridge/br_private.h
net/bridge/br_switchdev.c

index 83d6be3f87f1e5b2b094fb802bfe03bdc6544a4a..d4f6b398303daa89465875781180765306b8d007 100644 (file)
@@ -506,7 +506,6 @@ static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,
                        set_bit(BR_FDB_LOCAL, &fdb->flags);
                if (is_static)
                        set_bit(BR_FDB_STATIC, &fdb->flags);
-               fdb->offloaded = 0;
                fdb->updated = fdb->used = jiffies;
                if (rhashtable_lookup_insert_fast(&br->fdb_hash_tbl,
                                                  &fdb->rhnode,
@@ -656,7 +655,7 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br,
        ndm->ndm_ifindex = fdb->dst ? fdb->dst->dev->ifindex : br->dev->ifindex;
        ndm->ndm_state   = fdb_to_nud(br, fdb);
 
-       if (fdb->offloaded)
+       if (test_bit(BR_FDB_OFFLOADED, &fdb->flags))
                ndm->ndm_flags |= NTF_OFFLOADED;
        if (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags))
                ndm->ndm_flags |= NTF_EXT_LEARNED;
@@ -1188,8 +1187,8 @@ void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
        spin_lock_bh(&br->hash_lock);
 
        fdb = br_fdb_find(br, addr, vid);
-       if (fdb)
-               fdb->offloaded = offloaded;
+       if (fdb && offloaded != test_bit(BR_FDB_OFFLOADED, &fdb->flags))
+               change_bit(BR_FDB_OFFLOADED, &fdb->flags);
 
        spin_unlock_bh(&br->hash_lock);
 }
@@ -1208,7 +1207,7 @@ void br_fdb_clear_offload(const struct net_device *dev, u16 vid)
        spin_lock_bh(&p->br->hash_lock);
        hlist_for_each_entry(f, &p->br->fdb_list, fdb_node) {
                if (f->dst == p && f->key.vlan_id == vid)
-                       f->offloaded = 0;
+                       clear_bit(BR_FDB_OFFLOADED, &f->flags);
        }
        spin_unlock_bh(&p->br->hash_lock);
 }
index cf325177a34e5506fdf4689168c7cd3e8a8f58ec..f4754bf7f4bdc6006dc32ba06c2b0012823f2bad 100644 (file)
@@ -179,6 +179,7 @@ enum {
        BR_FDB_STICKY,
        BR_FDB_ADDED_BY_USER,
        BR_FDB_ADDED_BY_EXT_LEARN,
+       BR_FDB_OFFLOADED,
 };
 
 struct net_bridge_fdb_key {
@@ -193,7 +194,6 @@ struct net_bridge_fdb_entry {
        struct net_bridge_fdb_key       key;
        struct hlist_node               fdb_node;
        unsigned long                   flags;
-       unsigned char                   offloaded:1;
 
        /* write-heavy members should not affect lookups */
        unsigned long                   updated ____cacheline_aligned_in_smp;
index 5010fbf747783d85ee4ee37a43af4985bdcc0b81..015209bf44aa4391a1914e8dab4d469d18bd7dd7 100644 (file)
@@ -131,7 +131,8 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
                                                fdb->dst->dev,
                                                test_bit(BR_FDB_ADDED_BY_USER,
                                                         &fdb->flags),
-                                               fdb->offloaded);
+                                               test_bit(BR_FDB_OFFLOADED,
+                                                        &fdb->flags));
                break;
        case RTM_NEWNEIGH:
                br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr,
@@ -139,7 +140,8 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
                                                fdb->dst->dev,
                                                test_bit(BR_FDB_ADDED_BY_USER,
                                                         &fdb->flags),
-                                               fdb->offloaded);
+                                               test_bit(BR_FDB_OFFLOADED,
+                                                        &fdb->flags));
                break;
        }
 }