bridge: don't age out externally added FDB entries
Subsystems (5)
cover bridge: don't age out externally added FDB entries
From: Scott Feldman <[email protected]>
Siva originally proposed skipping externally added FDB entries in the bridge's FDB garbage collection func, and moving the ageing of externally added entries to the port driver/device. This broke rocker, since rocker didn't have a hardware (or software) mechanism for ageing out its learned FDB entries.
This patchset reintroduces Siva's bridge driver patch to skip externally added entries and adds support in rocker so rocker can age out its own entries. Rocker does this using a software timer similar to the bridge's FDB garbage collection timer. Other switchdev devices/drivers can use this software timer method or program the device to nofity aged-out entries to the driver.
Updated switchdev.txt documentation to reflect current state-of-the-art. This removes one more XXX todo comment in switchdev.txt.
Scott Feldman (6):
rocker: track when FDB entry is touched.
rocker: store rocker_port in fdb key rather than pport
rocker: adding port ageing_time for ageing out FDB entries
bridge: define some min/max ageing time constants we'll use next
rocker: add FDB cleanup timer
switchdev: update documentation on FDB ageing_time
Siva Mannem (1):
bridge: don't age externally added FDB entries
Documentation/networking/switchdev.txt | 24 +++++------ drivers/net/ethernet/rocker/rocker.c | 69 +++++++++++++++++++++++++++----- include/linux/if_bridge.h | 4 ++ net/bridge/br_fdb.c | 2 + 4 files changed, 77 insertions(+), 22 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/7 rocker: track when FDB entry is touched.
From: Scott Feldman <[email protected]>
The entry is touched once when created, and touched again for each update. The touched time is used to calculate FDB entry age.
--- drivers/net/ethernet/rocker/rocker.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/net/ethernet/rocker/rocker.c +12 -6
@@ -152,6 +152,7 @@ struct rocker_fdb_tbl_entry {struct hlist_node entry;u32 key_crc32;/* key */ bool learned; +unsigned long touched;struct rocker_fdb_tbl_key {u32 pport;u8 addr[ETH_ALEN ];
@@ -3629,6 +3630,7 @@ static int rocker_port_fdb(struct rocker_port *rocker_port,return -ENOMEM ; fdb->learned = (flags &ROCKER_OP_FLAG_LEARNED ); + fdb->touched = jiffies; fdb->key.pport = rocker_port->pport;ether_addr_copy (fdb->key.addr, addr); fdb->key.vlan_id = vlan_id;
@@ -3638,13 +3640,17 @@ static int rocker_port_fdb(struct rocker_port *rocker_port, found =rocker_fdb_tbl_find (rocker, fdb); -if (removing && found) { -rocker_port_kfree (trans, fdb); -if (trans !=SWITCHDEV_TRANS_PREPARE ) -hash_del (&found->entry); - }else if (!removing && !found) { +if (found) { + found->touched = jiffies; +if (removing) { +rocker_port_kfree (trans, fdb); +if (trans !=SWITCHDEV_TRANS_PREPARE ) +hash_del (&found->entry); + } + }else if (!removing) {if (trans !=SWITCHDEV_TRANS_PREPARE ) -hash_add (rocker->fdb_tbl, &fdb->entry, fdb->key_crc32); +hash_add (rocker->fdb_tbl, &fdb->entry, + fdb->key_crc32); }spin_unlock_irqrestore (&rocker->fdb_tbl_lock, lock_flags);
Signature · 1 line
1.7.10.4
PATCH 2/7 rocker: store rocker_port in fdb key rather than pport
In reply to [email protected]From: Scott Feldman <[email protected]>
We'll need more info from rocker_port than just pport when we age out fdb entries, so store rocker_port rather than pport in each fdb entry.
--- drivers/net/ethernet/rocker/rocker.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/rocker/rocker.c +4 -4
@@ -154,7 +154,7 @@ struct rocker_fdb_tbl_entry {bool learned;unsigned long touched;struct rocker_fdb_tbl_key { -u32 pport; +struct rocker_port *rocker_port;u8 addr[ETH_ALEN ];__be16 vlan_id; } key;
@@ -3631,7 +3631,7 @@ static int rocker_port_fdb(struct rocker_port *rocker_port, fdb->learned = (flags &ROCKER_OP_FLAG_LEARNED ); fdb->touched = jiffies; - fdb->key.pport = rocker_port->pport; + fdb->key.rocker_port = rocker_port;ether_addr_copy (fdb->key.addr, addr); fdb->key.vlan_id = vlan_id; fdb->key_crc32 =crc32 (~0 , &fdb->key,sizeof (fdb->key));
@@ -3686,7 +3686,7 @@ static int rocker_port_fdb_flush(struct rocker_port *rocker_port,spin_lock_irqsave (&rocker->fdb_tbl_lock, lock_flags);hash_for_each_safe (rocker->fdb_tbl, bkt, tmp, found, entry) { -if (found->key.pport != rocker_port->pport) +if (found->key.rocker_port != rocker_port)continue ;if (!found->learned)continue ;
@@ -4553,7 +4553,7 @@ static int rocker_port_fdb_dump(const struct rocker_port *rocker_port,spin_lock_irqsave (&rocker->fdb_tbl_lock, lock_flags);hash_for_each_safe (rocker->fdb_tbl, bkt, tmp, found, entry) { -if (found->key.pport != rocker_port->pport) +if (found->key.rocker_port != rocker_port)continue ; fdb->addr = found->key.addr; fdb->ndm_state =NUD_REACHABLE ;
Signature · 1 line
1.7.10.4
PATCH 3/7 rocker: adding port ageing_time for ageing out FDB entries
In reply to [email protected]From: Scott Feldman <[email protected]>
Follow-up patcheset will allow user to change ageing_time, but for now just hard-code it to a fixed value (the same value used as the default for the bridge driver).
--- drivers/net/ethernet/rocker/rocker.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/rocker/rocker.c +2 -0
@@ -221,6 +221,7 @@ struct rocker_port {__be16 internal_vlan_id;int stp_state;u32 brport_flags; +unsigned long ageing_time;bool ctrls[ROCKER_CTRL_MAX ];unsigned long vlan_bitmap[ROCKER_VLAN_BITMAP_LEN ];struct napi_struct napi_tx;
@@ -4975,6 +4976,7 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number) rocker_port->port_number = port_number; rocker_port->pport = port_number +1 ; rocker_port->brport_flags =BR_LEARNING |BR_LEARNING_SYNC ; + rocker_port->ageing_time =300 *HZ ;INIT_LIST_HEAD (&rocker_port->trans_mem);rocker_port_dev_addr_init (rocker_port);
Signature · 1 line
1.7.10.4
PATCH 4/7 bridge: define some min/max ageing time constants we'll use next
In reply to [email protected]From: Scott Feldman <[email protected]>
--- include/linux/if_bridge.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/if_bridge.h +4 -0
@@ -46,6 +46,10 @@ struct br_ip_list {#define BR_LEARNING_SYNC BIT(9)#define BR_PROXYARP_WIFI BIT(10) +/* values as per ieee8021QBridgeFdbAgingTime */ +#define BR_MIN_AGEING_TIME (10 * HZ) +#define BR_MAX_AGEING_TIME (1000000 * HZ) +extern void brioctl_set (int (*ioctl_hook)(struct net *,unsigned int ,void __user *));typedef int br_should_route_hook_t (struct sk_buff *skb);
Signature · 1 line
1.7.10.4
PATCH 5/7 rocker: add FDB cleanup timer
In reply to [email protected]From: Scott Feldman <[email protected]>
Add a timer to each rocker switch to do FDB entry cleanup by ageing out expired entries. The timer scheduling algo is copied from the bridge driver, for the most part, to keep the firing of the timer to a minimum.
--- drivers/net/ethernet/rocker/rocker.c | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/net/ethernet/rocker/rocker.c +41 -0
@@ -248,6 +248,7 @@ struct rocker {u64 flow_tbl_next_cookie;DECLARE_HASHTABLE (group_tbl,16 );spinlock_t group_tbl_lock;/* for group tbl accesses */ +struct timer_list fdb_cleanup_timer;DECLARE_HASHTABLE (fdb_tbl,16 );spinlock_t fdb_tbl_lock;/* for fdb tbl accesses */ unsigned long internal_vlan_bitmap[ROCKER_INTERNAL_VLAN_BITMAP_LEN ];
@@ -3706,6 +3707,41 @@ err_out:return err; } +static void rocker_fdb_cleanup (unsigned long data) +{ +struct rocker *rocker = (struct rocker *)data; +struct rocker_port *rocker_port; +struct rocker_fdb_tbl_entry *entry; +struct hlist_node *tmp; +unsigned long next_timer = jiffies +BR_MIN_AGEING_TIME ; +unsigned long expires; +unsigned long lock_flags; +int flags =ROCKER_OP_FLAG_NOWAIT |ROCKER_OP_FLAG_REMOVE | +ROCKER_OP_FLAG_LEARNED ; +int bkt; + +spin_lock_irqsave (&rocker->fdb_tbl_lock, lock_flags); + +hash_for_each_safe (rocker->fdb_tbl, bkt, tmp, entry, entry) { +if (!entry->learned) +continue ; + rocker_port = entry->key.rocker_port; + expires = entry->touched + rocker_port->ageing_time; +if (time_before_eq (expires, jiffies)) { +rocker_port_fdb_learn (rocker_port,SWITCHDEV_TRANS_NONE , + flags, entry->key.addr, + entry->key.vlan_id); +hash_del (&entry->entry); + }else if (time_before (expires, next_timer)) { + next_timer = expires; + } + } + +spin_unlock_irqrestore (&rocker->fdb_tbl_lock, lock_flags); + +mod_timer (&rocker->fdb_cleanup_timer,round_jiffies_up (next_timer)); +} +static int rocker_port_router_mac (struct rocker_port *rocker_port,enum switchdev_trans trans,int flags,__be16 vlan_id)
@@ -5191,6 +5227,10 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_init_tbls; } +setup_timer (&rocker->fdb_cleanup_timer, rocker_fdb_cleanup, + (unsigned long ) rocker); +mod_timer (&rocker->fdb_cleanup_timer, jiffies); + err =rocker_probe_ports (rocker);if (err) {dev_err (&pdev->dev,"failed to probe ports\n" );
@@ -5203,6 +5243,7 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ; err_probe_ports: +del_timer (&rocker->fdb_cleanup_timer);rocker_free_tbls (rocker); err_init_tbls:free_irq (rocker_msix_vector (rocker,ROCKER_MSIX_VEC_EVENT ), rocker);
Signature · 1 line
1.7.10.4
PATCH 6/7 bridge: don't age externally added FDB entries
In reply to [email protected]From: Siva Mannem <[email protected]>
--- net/bridge/br_fdb.c | 2 ++ 1 file changed, 2 insertions(+)
net/bridge/br_fdb.c +2 -0
@@ -299,6 +299,8 @@ void br_fdb_cleanup(unsigned long _data)unsigned long this_timer;if (f->is_static)continue ; +if (f->added_by_external_learn) +continue ; this_timer = f->updated + delay;if (time_before_eq (this_timer, jiffies))fdb_delete (br, f);
Signature · 1 line
1.7.10.4
PATCH 7/7 switchdev: update documentation on FDB ageing_time
In reply to [email protected]From: Scott Feldman <[email protected]>
--- Documentation/networking/switchdev.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
Documentation/networking/switchdev.txt +12 -12
@@ -239,20 +239,20 @@ The driver should initialize the attributes to the hardware defaults. FDB Ageing ^^^^^^^^^^ -There are two FDB ageing models supported: 1) ageing by the device, and 2) -ageing by the kernel. Ageing by the device is preferred if many FDB entries -are supported. The driver calls call_switchdev_notifiers(SWITCHDEV_FDB_DEL, -...) to age out the FDB entry. In this model, ageing by the kernel should be -turned off. XXX: how to turn off ageing in kernel on a per-port basis or -otherwise prevent the kernel from ageing out the FDB entry? - -In the kernel ageing model, the standard bridge ageing mechanism is used to age -out stale FDB entries. To keep an FDB entry "alive", the driver should refresh -the FDB entry by calling call_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). The +The bridge will skip ageing FDB entries marked with NTF_EXT_LEARNED and it is +the responsibility of the port driver/device to age out these entries. If the +port device supports ageing, when the FDB entry expires, it will notify the +driver which in turn will notify the bridge with SWITCHDEV_FDB_DEL. If the +device does not support ageing, the driver can simulate ageing using a +garbage collection timer to monitor FBD entries. Expired entries will be +notified to the bridge using SWITCHDEV_FDB_DEL. See rocker driver for +example of driver running ageing timer. + +To keep an NTF_EXT_LEARNED entry "alive", the driver should refresh the FDB +entry by calling call_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). The notification will reset the FDB entry's last-used time to now. The driver should rate limit refresh notifications, for example, no more than once a -second. If the FDB entry expires, fdb_delete is called to remove entry from -the device. +second. (The last-used time is visible using the bridge -s fdb option). STP State Change on Port ^^^^^^^^^^^^^^^^^^^^^^^^
Signature · 1 line
1.7.10.4
Re: [PATCH net-next 6/7] bridge: don't age externally added FDB entries
In reply to [email protected]Quoted 4 lines · On Sep. Friday 18 (38) 12:55 PM, [email protected] wrote:
From: Siva Mannem <[email protected]>
Signed-off-by Siva Mannem <[email protected]>Signed-off-by Scott Feldman <[email protected]>
Re: [PATCH net-next 7/7] switchdev: update documentation on FDB ageing_time
In reply to [email protected]Quoted 3 lines · On Sep. Friday 18 (38) 12:55 PM, [email protected] wrote:
From: Scott Feldman <[email protected]>
Signed-off-by Scott Feldman <[email protected]>
Jiri Pirko
maintainerRe: [PATCH net-next 3/7] rocker: adding port ageing_time for ageing out FDB entries
In reply to [email protected]Quoted 24 lines · Fri, Sep 18, 2015 at 09:55:47PM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
Follow-up patcheset will allow user to change
ageing_time, but for now just hard-code it to a fixed value (the same value used as the default for the bridge driver).Signed-off-by Scott Feldman <[email protected]>---
drivers/net/ethernet/rocker/rocker.c| 2 ++1 file changed, 2 insertions(+)drivers/net/ethernet/rocker/rocker.c +1
-0@@ -221,6 +221,7 @@ struct rocker_port {__be16 internal_vlan_id;int stp_state;u32 brport_flags; +unsigned long ageing_time;bool ctrls[ROCKER_CTRL_MAX ];unsigned long vlan_bitmap[ROCKER_VLAN_BITMAP_LEN ];struct napi_struct napi_tx;
drivers/net/ethernet/rocker/rocker.c static int rocker_probe_port(struct rocker *rocker, unsigned int port_number) · line 4979
Quoted 4 lines
drivers/net/ethernet/rocker/rocker.c +1
-0@@ -4975,6 +4976,7 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number) rocker_port->port_number = port_number; rocker_port->pport = port_number +1 ; rocker_port->brport_flags =BR_LEARNING |BR_LEARNING_SYNC ; + rocker_port->ageing_time =300 *HZ ;
How about to add also "BR_DEFAULT_AGEING_TIME" and use it here?
Quoted 1 line
Re: [PATCH net-next 1/7] rocker: track when FDB entry is touched.
In reply to [email protected]Quoted 6 lines · Fri, Sep 18, 2015 at 09:55:45PM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
The entry is touched once when created, and touched again for each update. The touched time is used to calculate FDB entry age.
Signed-off-by Scott Feldman <[email protected]>
Re: [PATCH net-next 2/7] rocker: store rocker_port in fdb key rather than pport
In reply to [email protected]Quoted 6 lines · Fri, Sep 18, 2015 at 09:55:46PM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
We'll need more info from
rocker_portthan just pport when we age out fdb entries, so storerocker_portrather than pport in each fdb entry.Signed-off-by Scott Feldman <[email protected]>
Jiri Pirko
maintainerRe: [PATCH net-next 4/7] bridge: define some min/max ageing time constants we'll use next
In reply to [email protected]Quoted 12 lines · Fri, Sep 18, 2015 at 09:55:48PM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
Signed-off-by Scott Feldman <[email protected]>---
include/linux/if_bridge.h| 4 ++++1 file changed, 4 insertions(+)include/linux/if_bridge.h +0
-0
include/linux/if_bridge.h struct br_ip_list { · line 51
Quoted 6 lines
include/linux/if_bridge.h +3
-0@@ -46,6 +46,10 @@ struct br_ip_list {#define BR_LEARNING_SYNC BIT(9)#define BR_PROXYARP_WIFI BIT(10) +/* values as per ieee8021QBridgeFdbAgingTime */ +#define BR_MIN_AGEING_TIME (10 * HZ) +#define BR_MAX_AGEING_TIME (1000000 * HZ)
I think that a bridge patch checking against these values should be introduced along with these values, in the same patchset
Re: [PATCH net-next 5/7] rocker: add FDB cleanup timer
In reply to [email protected]Quoted 7 lines · Fri, Sep 18, 2015 at 09:55:49PM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
Add a timer to each rocker switch to do FDB entry cleanup by ageing out expired entries. The timer scheduling algo is copied from the bridge driver, for the most part, to keep the firing of the timer to a minimum.
Signed-off-by Scott Feldman <[email protected]>
Re: [PATCH net-next 6/7] bridge: don't age externally added FDB entries
In reply to [email protected]Quoted 4 lines · Fri, Sep 18, 2015 at 09:55:50PM CEST, [email protected] wrote:
From: Siva Mannem <[email protected]>
Signed-off-by Siva Mannem <[email protected]>Signed-off-by Scott Feldman <[email protected]>
Re: [PATCH net-next 7/7] switchdev: update documentation on FDB ageing_time
In reply to [email protected]Quoted 3 lines · Fri, Sep 18, 2015 at 09:55:51PM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
Signed-off-by Scott Feldman <[email protected]>
Re: [PATCH net-next 3/7] rocker: adding port ageing_time for ageing out FDB entries
In reply to Jiri PirkoQuoted 23 lines · Jiri Pirko
Quoted 22 lines · Fri, Sep 18, 2015 at 09:55:47PM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
Follow-up patcheset will allow user to change
ageing_time, but for now just hard-code it to a fixed value (the same value used as the default for the bridge driver).Signed-off-by Scott Feldman <[email protected]>---
drivers/net/ethernet/rocker/rocker.c| 2 ++1 file changed, 2 insertions(+)drivers/net/ethernet/rocker/rocker.c +1
-0@@ -221,6 +221,7 @@ struct rocker_port {__be16 internal_vlan_id;int stp_state;u32 brport_flags; +unsigned long ageing_time;bool ctrls[ROCKER_CTRL_MAX ];unsigned long vlan_bitmap[ROCKER_VLAN_BITMAP_LEN ];
Quoted 8 lines
drivers/net/ethernet/rocker/rocker.c static int rocker_probe_port(struct rocker *rocker, unsigned int port_number) · line 4979
Quoted 6 lines
drivers/net/ethernet/rocker/rocker.c +1
-0struct napi_struct napi_tx;@@ -4975,6 +4976,7 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number) rocker_port->port_number = port_number; rocker_port->pport = port_number +1 ; rocker_port->brport_flags =BR_LEARNING |BR_LEARNING_SYNC ; + rocker_port->ageing_time =300 *HZ ;How about to add also "
BR_DEFAULT_AGEING_TIME" and use it here?
Yes, added for v2
Re: [PATCH net-next 4/7] bridge: define some min/max ageing time constants we'll use next
In reply to Jiri PirkoQuoted 16 lines · Jiri Pirko
Quoted 15 lines · Fri, Sep 18, 2015 at 09:55:48PM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
Signed-off-by Scott Feldman <[email protected]>---
include/linux/if_bridge.h| 4 ++++1 file changed, 4 insertions(+)include/linux/if_bridge.h +0
-0@@ -46,6 +46,10 @@ struct br_ip_list {#define BR_LEARNING_SYNC BIT(9)#define BR_PROXYARP_WIFI BIT(10)
Quoted 6 lines
include/linux/if_bridge.h struct br_ip_list { · line 51
Quoted 3 lines
include/linux/if_bridge.h +3
-0+/* values as per ieee8021QBridgeFdbAgingTime */ +#define BR_MIN_AGEING_TIME (10 * HZ) +#define BR_MAX_AGEING_TIME (1000000 * HZ)I think that a bridge patch checking against these values should be introduced along with these values, in the same patchset
I need the MIN value for this patchset in rocker's ageing timer, so it's introduced here. MIN/MAX will be used again in follow-on patch Prem is going to send to range check user input.
Re: [PATCH net-next 7/7] switchdev: update documentation on FDB ageing_time
In reply to [email protected]Quoted 23 lines · On 9/18/15, 12:55 PM, [email protected] wrote:
From: Scott Feldman <[email protected]>
Signed-off-by Scott Feldman <[email protected]>--- Documentation/networking/switchdev.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)Documentation/networking/switchdev.txt +0
-8@@ -239,20 +239,20 @@ The driver should initialize the attributes to the hardware defaults. FDB Ageing ^^^^^^^^^^ -There are two FDB ageing models supported: 1) ageing by the device, and 2) -ageing by the kernel. Ageing by the device is preferred if many FDB entries -are supported. The driver calls call_switchdev_notifiers(SWITCHDEV_FDB_DEL, -...) to age out the FDB entry. In this model, ageing by the kernel should be -turned off. XXX: how to turn off ageing in kernel on a per-port basis or -otherwise prevent the kernel from ageing out the FDB entry? - -In the kernel ageing model, the standard bridge ageing mechanism is used to age
Documentation/networking/switchdev.txt The driver should initialize the attributes to the hardware defaults. · line 249
Quoted 10 lines
Documentation/networking/switchdev.txt +8
-2-out stale FDB entries. To keep an FDB entry "alive", the driver should refresh -the FDB entry by calling call_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). The +The bridge will skip ageing FDB entries marked with NTF_EXT_LEARNED and it is +the responsibility of the port driver/device to age out these entries. If the +port device supports ageing, when the FDB entry expires, it will notify the +driver which in turn will notify the bridge with SWITCHDEV_FDB_DEL. If the +device does not support ageing, the driver can simulate ageing using a +garbage collection timer to monitor FBD entries. Expired entries will be +notified to the bridge using SWITCHDEV_FDB_DEL. See rocker driver for +example of driver running ageing timer.
We do rely on the bridge driver ageing out entries. We have gone from hardware ageing to ageing in the switch driver to ultimately ageing in the bridge driver. :). And we keep the fdb entries in the bridge driver "alive" by using 'NTF_USE' from the user-space driver.
Documentation/networking/switchdev.txt The driver should initialize the attributes to the hardware defaults. · line 256
Quoted 4 lines
Documentation/networking/switchdev.txt +3
-0+ +To keep an NTF_EXT_LEARNED entry "alive", the driver should refresh the FDB +entry by calling call_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). The
Even with your current patches, looks like the switch driver will need to refresh the entries anyways to keep the "last-used" time to now. In which case is there much value in switch driver doing the ageing ?.
I am thinking keeping the default behavior of the bridge driver to age and anything else configurable might be a better option.
Thanks,
Roopa
Re: [PATCH net-next 7/7] switchdev: update documentation on FDB ageing_time
Quoted 44 lines · roopa
Quoted 43 lines · On 9/18/15, 12:55 PM, [email protected] wrote:
From: Scott Feldman <[email protected]>
Signed-off-by Scott Feldman <[email protected]>--- Documentation/networking/switchdev.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)Documentation/networking/switchdev.txt +0
-0@@ -239,20 +239,20 @@ The driver should initialize the attributes to thehardware defaults.
FDB Ageing
^^^^^^^^^^
-There are two FDB ageing models supported: 1) ageing by the device, and
2)
-ageing by the kernel. Ageing by the device is preferred if many FDB entries
-are supported. The driver calls call_switchdev_notifiers(SWITCHDEV_FDB_DEL,
-...) to age out the FDB entry. In this model, ageing by the kernel should beDocumentation/networking/switchdev.txt +0
-4-turned off. XXX: how to turn off ageing in kernel on a per-port basis or -otherwise prevent the kernel from ageing out the FDB entry? - -In the kernel ageing model, the standard bridge ageing mechanism is usedto age
-out stale FDB entries. To keep an FDB entry "alive", the driver should refresh
-the FDB entry by callingcall_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). The
+The bridge will skip ageing FDB entries marked withNTF_EXT_LEARNEDand it is
+the responsibility of the port driver/device to age out these entries. If the
+port device supports ageing, when the FDB entry expires, it will notify the
+driver which in turn will notify the bridge withSWITCHDEV_FDB_DEL. If the
+device does not support ageing, the driver can simulate ageing using a
Quoted 8 lines
Documentation/networking/switchdev.txt The driver should initialize the attributes to the hardware defaults. · line 249
Quoted 3 lines
Documentation/networking/switchdev.txt +3
-0+garbage collection timer to monitor FBD entries. Expired entries will be +notified to the bridge using SWITCHDEV_FDB_DEL. See rocker driver for +example of driver running ageing timer.We do rely on the bridge driver ageing out entries. We have gone from hardware ageing to ageing in the switch driver to ultimately ageing in the bridge driver. :). And we keep the fdb entries in the bridge driver "alive" by using '
NTF_USE' from the user-space driver.
Yes, your switch driver is in user-space so you have to use NTF_USE to refresh the entry since you cannot use the kernel driver model to call_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). Consequently, your entries are not marked with NTF_EXT_LEARNED, so this patch is a no-op for you. You can continue to use the bridge driver to age out your entries.
Quoted 7 lines
Quoted 4 lines
+To keep an
NTF_EXT_LEARNEDentry "alive", the driver should refresh the FDB
+entry by callingcall_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). TheEven with your current patches, looks like the switch driver will need to refresh the entries anyways to keep the "last-used" time to now. In which case is there much value in switch driver doing the ageing ?.
"should" not "must".
Value is for the many learned FDB entries case, to move the ageing function to hardware.
Quoted 2 lines
I am thinking keeping the default behavior of the bridge driver to age and anything else configurable might be a better option.
I'd rather someone add that knob when it's actually needed. When the first in-kernel switchdev driver that wants to use the bridge driver's ageing function, then we can make that adjustment.
Re: [PATCH net-next 7/7] switchdev: update documentation on FDB ageing_time
Quoted 6 lines · Scott Feldman
Yes, your switch driver is in user-space so you have to use
NTF_USEto refresh the entry since you cannot use the kernel driver model tocall_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). Consequently, your entries are not marked withNTF_EXT_LEARNED, so this patch is a no-op for you. You can continue to use the bridge driver to age out your entries.
yes, correct. I was not really saying this because it will cause us any problems. I was trying to say this for switchdev in general.
Quoted 1 line
I'd rather someone add that knob when it's actually needed. When the first in-kernel switchdev driver that wants to use the bridge driver's ageing function, then we can make that adjustment.
I was suggesting the other way around. Keep the default to what is in the kernel today and the first in-kernel switchdev driver that wants to age,
should introduce the ability to not age in the bridge driver (Rocker will continue to work as it does today). Because, I am only concerned that rocker may end up being the only device that uses the default behavior introduced by this patch. And every real hardware uses the bridge driver to age (because there are no in kernel examples today). I am curious to know who else is using hardware ageing today.
Re: [PATCH net-next 7/7] switchdev: update documentation on FDB ageing_time
Quoted 17 lines · roopa
Quoted 7 lines · Scott Feldman
Yes, your switch driver is in user-space so you have to use
NTF_USEto refresh the entry since you cannot use the kernel driver model tocall_switchdev_notifiers(SWITCHDEV_FDB_ADD, ...). Consequently, your entries are not marked withNTF_EXT_LEARNED, so this patch is a no-op for you. You can continue to use the bridge driver to age out your entries.yes, correct. I was not really saying this because it will cause us any problems.
I was trying to say this for switchdev in general.Quoted 3 lines
I'd rather someone add that knob when it's actually needed. When the first in-kernel switchdev driver that wants to use the bridge driver's ageing function, then we can make that adjustment.
Quoted 8 lines
I was suggesting the other way around. Keep the default to what is in the kernel today and the first in-kernel switchdev driver that wants to age, should introduce the ability to not age in the bridge driver (Rocker will continue to work as it does today). Because, I am only concerned that rocker may end up being the only device that uses the default behavior introduced by this patch. And every real hardware uses the bridge driver to age (because there are no in kernel examples today). I am curious to know who else is using hardware ageing today.
A driver patch for a (real) hardware device which does the ageing in hw is around the corner.
RE: [PATCH net-next 6/7] bridge: don't age externally added FDB entries
In reply to [email protected]Quoted 4 lines
From: Siva Mannem <[email protected]>
Signed-off-by Siva Mannem <[email protected]>Signed-off-by Scott Feldman <[email protected]>
Quoted 19 lines
--- net/bridge/br_fdb.c | 2 ++ 1 file changed, 2 insertions(+)net/bridge/br_fdb.c +2
-1@@ -299,6 +299,8 @@ void br_fdb_cleanup(unsigned long _data)unsigned long this_timer;if (f->is_static)continue ; +if (f->added_by_external_learn) +continue ; this_timer = f->updated + delay;if (time_before_eq (this_timer, jiffies))fdb_delete (br, f); --1.7.10.4
RE: [PATCH net-next 4/7] bridge: define some min/max ageing time constants we'll use next
In reply to Scott FeldmanQuoted 35 lines
-----Original Message-----
From: Scott Feldman [mailto:[email protected]]
Sent: Saturday, September 19, 2015 10:51 PM
To: Jiri Pirko
Cc: Netdev; Siva Mannem; Premkumar Jonnala; [email protected]; Roopa Prabhu; [email protected]; Florian Fainelli; Vivien Didelot
Subject: Re: [PATCH net-next 4/7] bridge: define some min/max ageing time constants we'll use nextQuoted 16 lines · Jiri Pirko
Quoted 15 lines · Fri, Sep 18, 2015 at 09:55:48PM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
Signed-off-by Scott Feldman <[email protected]>---
include/linux/if_bridge.h| 4 ++++1 file changed, 4 insertions(+)include/linux/if_bridge.h +0
-0@@ -46,6 +46,10 @@ struct br_ip_list {#define BR_LEARNING_SYNC BIT(9)#define BR_PROXYARP_WIFI BIT(10)Quoted 6 lines
include/linux/if_bridge.h struct br_ip_list { · line 51
Quoted 3 lines
include/linux/if_bridge.h +3
-0+/* values as per ieee8021QBridgeFdbAgingTime */ +#define BR_MIN_AGEING_TIME (10 * HZ) +#define BR_MAX_AGEING_TIME (1000000 * HZ)I think that a bridge patch checking against these values should be introduced along with these values, in the same patchset
Quoted 3 lines
I need the MIN value for this patchset in rocker's ageing timer, so it's introduced here. MIN/MAX will be used again in follow-on patch Prem is going to send to range check user input.
Ack that. I will add those checks as part of the patch for iproute2.
-Prem