--- zzzz-none-000/linux-5.15.111/net/bridge/br_sysfs_br.c 2023-05-11 14:00:40.000000000 +0000 +++ puma7-atom-6670-761/linux-5.15.111/net/bridge/br_sysfs_br.c 2024-02-07 10:23:29.000000000 +0000 @@ -835,6 +835,73 @@ return store_bridge_parm(d, buf, len, set_nf_call_arptables); } static DEVICE_ATTR_RW(nf_call_arptables); + +static ssize_t show_nf_disable_iptables( + struct device *d, struct device_attribute *attr, char *buf) +{ + struct net_bridge *br = to_bridge(d); + return sprintf(buf, "%u\n", br->nf_disable_iptables); +} + +static int set_nf_disable_iptables(struct net_bridge *br, unsigned long val, struct netlink_ext_ack *extack) +{ + br->nf_disable_iptables = val ? true : false; + return 0; +} + +static ssize_t store_nf_disable_iptables( + struct device *d, struct device_attribute *attr, const char *buf, + size_t len) +{ + return store_bridge_parm(d, buf, len, set_nf_disable_iptables); +} +static DEVICE_ATTR(nf_disable_iptables, S_IRUGO | S_IWUSR, + show_nf_disable_iptables, store_nf_disable_iptables); + +static ssize_t show_nf_disable_ip6tables( + struct device *d, struct device_attribute *attr, char *buf) +{ + struct net_bridge *br = to_bridge(d); + return sprintf(buf, "%u\n", br->nf_disable_ip6tables); +} + +static int set_nf_disable_ip6tables(struct net_bridge *br, unsigned long val, struct netlink_ext_ack *extack) +{ + br->nf_disable_ip6tables = val ? true : false; + return 0; +} + +static ssize_t store_nf_disable_ip6tables( + struct device *d, struct device_attribute *attr, const char *buf, + size_t len) +{ + return store_bridge_parm(d, buf, len, set_nf_disable_ip6tables); +} +static DEVICE_ATTR(nf_disable_ip6tables, S_IRUGO | S_IWUSR, + show_nf_disable_ip6tables, store_nf_disable_ip6tables); + +static ssize_t show_nf_disable_arptables( + struct device *d, struct device_attribute *attr, char *buf) +{ + struct net_bridge *br = to_bridge(d); + return sprintf(buf, "%u\n", br->nf_disable_arptables); +} + +static int set_nf_disable_arptables(struct net_bridge *br, unsigned long val, struct netlink_ext_ack *extack) +{ + br->nf_disable_arptables = val ? true : false; + return 0; +} + +static ssize_t store_nf_disable_arptables( + struct device *d, struct device_attribute *attr, const char *buf, + size_t len) +{ + return store_bridge_parm(d, buf, len, set_nf_disable_arptables); +} +static DEVICE_ATTR(nf_disable_arptables, S_IRUGO | S_IWUSR, + show_nf_disable_arptables, store_nf_disable_arptables); + #endif #ifdef CONFIG_BRIDGE_VLAN_FILTERING static ssize_t vlan_filtering_show(struct device *d, @@ -930,6 +997,59 @@ static DEVICE_ATTR_RW(vlan_stats_per_port); #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(avm_flood_ratelimit, S_IRUGO | S_IWUSR, + avm_flood_ratelimit_show, avm_flood_ratelimit_store); + +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 int set_rate(struct net_bridge *br, unsigned long v, + struct netlink_ext_ack *extack) +{ + 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(avm_flood_ratelimit_recover_rate, S_IRUGO | S_IWUSR, + avm_flood_ratelimit_recover_rate_show, + avm_flood_ratelimit_recover_rate_store); +#endif + static struct attribute *bridge_attrs[] = { &dev_attr_forward_delay.attr, &dev_attr_hello_time.attr, @@ -976,6 +1096,9 @@ &dev_attr_nf_call_iptables.attr, &dev_attr_nf_call_ip6tables.attr, &dev_attr_nf_call_arptables.attr, + &dev_attr_nf_disable_iptables.attr, + &dev_attr_nf_disable_ip6tables.attr, + &dev_attr_nf_disable_arptables.attr, #endif #ifdef CONFIG_BRIDGE_VLAN_FILTERING &dev_attr_vlan_filtering.attr, @@ -984,6 +1107,10 @@ &dev_attr_vlan_stats_enabled.attr, &dev_attr_vlan_stats_per_port.attr, #endif +#ifdef CONFIG_AVM_BRIDGE_FLOOD_RATELIMITER + &dev_attr_avm_flood_ratelimit.attr, + &dev_attr_avm_flood_ratelimit_recover_rate.attr, +#endif NULL };