--- zzzz-none-000/linux-4.4.271/net/bridge/br_sysfs_br.c 2021-06-03 06:22:09.000000000 +0000 +++ maple-fsgw-759/linux-4.4.271/net/bridge/br_sysfs_br.c 2023-12-20 10:37:40.000000000 +0000 @@ -750,6 +750,56 @@ static DEVICE_ATTR_RW(default_pvid); #endif +#ifdef CONFIG_AVM_BRIDGE_FLOOD_RATELIMITER + +static ssize_t avm_flood_ratelimit_show(struct device *d, + struct device_attribute *attr, + char *buf) +{ + struct net_bridge *br = to_bridge(d); + return sprintf(buf, "%d\n%d\n", br->avm_flood_credits_max, + atomic_read(&br->avm_flood_credits)); +} + +static ssize_t avm_flood_ratelimit_store(struct device *d, + struct device_attribute *attr, + const char *buf, size_t len) +{ + /* Specify an initial amount of packets that are not rate limited */ + return store_bridge_parm(d, buf, len, br_flood_rl_set_credits); +} + +static DEVICE_ATTR_RW(avm_flood_ratelimit); + +static ssize_t avm_flood_ratelimit_recover_rate_show(struct device *d, + struct device_attribute *attr, + char *buf) +{ + struct net_bridge *br = to_bridge(d); + return sprintf(buf, "%d\n", br->avm_flood_credits_recov_rate); +} + + +static ssize_t set_rate(struct net_bridge *br, unsigned long v) +{ + if (v > INT_MAX) + return -EINVAL; + + br->avm_flood_credits_recov_rate = v; + return 0; +} + +static ssize_t avm_flood_ratelimit_recover_rate_store(struct device *d, + struct device_attribute *attr, + const char *buf, size_t len) +{ + /* Specify packets per seconds */ + return store_bridge_parm(d, buf, len, set_rate); +} + +static DEVICE_ATTR_RW(avm_flood_ratelimit_recover_rate); +#endif + static struct attribute *bridge_attrs[] = { &dev_attr_forward_delay.attr, &dev_attr_hello_time.attr, @@ -796,6 +846,10 @@ &dev_attr_vlan_protocol.attr, &dev_attr_default_pvid.attr, #endif +#ifdef CONFIG_AVM_BRIDGE_FLOOD_RATELIMITER + &dev_attr_avm_flood_ratelimit.attr, + &dev_attr_avm_flood_ratelimit_recover_rate.attr, +#endif NULL };