1 From 11c3fae5afa6cac444d12622e2cf5af60a99c1ef Mon Sep 17 00:00:00 2001
2 From: OpenWrt community <openwrt-devel@lists.openwrt.org>
3 Date: Wed, 13 Jul 2022 13:43:15 +0200
4 Subject: [PATCH] net/bridge: add bridge offload
7 include/linux/if_bridge.h | 1 +
8 net/bridge/Makefile | 2 +-
10 net/bridge/br_device.c | 2 +
11 net/bridge/br_fdb.c | 5 +
12 net/bridge/br_forward.c | 3 +
13 net/bridge/br_if.c | 6 +-
14 net/bridge/br_input.c | 5 +
15 net/bridge/br_offload.c | 438 ++++++++++++++++++++++++++++++++
16 net/bridge/br_private.h | 22 +-
17 net/bridge/br_private_offload.h | 23 ++
18 net/bridge/br_stp.c | 3 +
19 net/bridge/br_sysfs_br.c | 35 +++
20 net/bridge/br_sysfs_if.c | 2 +
21 net/bridge/br_vlan_tunnel.c | 3 +
22 15 files changed, 555 insertions(+), 3 deletions(-)
23 create mode 100644 net/bridge/br_offload.c
24 create mode 100644 net/bridge/br_private_offload.h
26 --- a/include/linux/if_bridge.h
27 +++ b/include/linux/if_bridge.h
28 @@ -60,6 +60,7 @@ struct br_ip_list {
29 #define BR_TX_FWD_OFFLOAD BIT(20)
30 #define BR_PORT_LOCKED BIT(21)
31 #define BR_BPDU_FILTER BIT(22)
32 +#define BR_OFFLOAD BIT(23)
34 #define BR_DEFAULT_AGEING_TIME (300 * HZ)
36 --- a/net/bridge/Makefile
37 +++ b/net/bridge/Makefile
40 obj-$(CONFIG_BRIDGE) += bridge.o
42 -bridge-y := br.o br_device.o br_fdb.o br_forward.o br_if.o br_input.o \
43 +bridge-y := br.o br_device.o br_fdb.o br_forward.o br_if.o br_input.o br_offload.o \
44 br_ioctl.o br_stp.o br_stp_bpdu.o \
45 br_stp_if.o br_stp_timer.o br_netlink.o \
46 br_netlink_tunnel.o br_arp_nd_proxy.o
50 #include <net/switchdev.h>
52 #include "br_private.h"
53 +#include "br_private_offload.h"
56 * Handle changes in state of network devices enslaved to a bridge.
57 @@ -389,6 +390,10 @@ static int __init br_init(void)
61 + err = br_offload_init();
65 err = register_pernet_subsys(&br_net_ops);
68 @@ -438,6 +443,8 @@ err_out3:
70 unregister_pernet_subsys(&br_net_ops);
76 stp_proto_unregister(&br_stp_proto);
77 @@ -460,6 +467,7 @@ static void __exit br_deinit(void)
78 #if IS_ENABLED(CONFIG_ATM_LANE)
79 br_fdb_test_addr_hook = NULL;
85 --- a/net/bridge/br_device.c
86 +++ b/net/bridge/br_device.c
87 @@ -525,6 +525,8 @@ void br_dev_setup(struct net_device *dev
88 br->bridge_hello_time = br->hello_time = 2 * HZ;
89 br->bridge_forward_delay = br->forward_delay = 15 * HZ;
90 br->bridge_ageing_time = br->ageing_time = BR_DEFAULT_AGEING_TIME;
91 + br->offload_cache_size = 128;
92 + br->offload_cache_reserved = 8;
93 dev->max_mtu = ETH_MAX_MTU;
95 br_netfilter_rtable_init(br);
96 --- a/net/bridge/br_fdb.c
97 +++ b/net/bridge/br_fdb.c
99 #include <net/switchdev.h>
100 #include <trace/events/bridge.h>
101 #include "br_private.h"
102 +#include "br_private_offload.h"
104 static const struct rhashtable_params br_fdb_rht_params = {
105 .head_offset = offsetof(struct net_bridge_fdb_entry, rhnode),
106 @@ -185,6 +186,8 @@ static void fdb_notify(struct net_bridge
110 + br_offload_fdb_update(fdb);
113 br_switchdev_fdb_notify(br, fdb, type);
115 @@ -393,6 +396,8 @@ static struct net_bridge_fdb_entry *fdb_
116 fdb->key.vlan_id = vid;
118 fdb->updated = fdb->used = jiffies;
119 + INIT_HLIST_HEAD(&fdb->offload_in);
120 + INIT_HLIST_HEAD(&fdb->offload_out);
121 err = rhashtable_lookup_insert_fast(&br->fdb_hash_tbl, &fdb->rhnode,
124 --- a/net/bridge/br_forward.c
125 +++ b/net/bridge/br_forward.c
127 #include <linux/if_vlan.h>
128 #include <linux/netfilter_bridge.h>
129 #include "br_private.h"
130 +#include "br_private_offload.h"
132 /* Don't forward packets to originating port or forwarding disabled */
133 static inline int should_deliver(const struct net_bridge_port *p,
134 @@ -32,6 +33,8 @@ static inline int should_deliver(const s
136 int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
138 + br_offload_output(skb);
140 skb_push(skb, ETH_HLEN);
141 if (!is_skb_forwardable(skb->dev, skb))
143 --- a/net/bridge/br_if.c
144 +++ b/net/bridge/br_if.c
146 #include <net/net_namespace.h>
148 #include "br_private.h"
149 +#include "br_private_offload.h"
152 * Determine initial path cost based on speed.
153 @@ -437,7 +438,7 @@ static struct net_bridge_port *new_nbp(s
154 p->path_cost = port_cost(dev);
155 p->priority = 0x8000 >> BR_PORT_BITS;
157 - p->flags = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD;
158 + p->flags = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD | BR_OFFLOAD;
160 br_set_state(p, BR_STATE_DISABLED);
161 br_stp_port_timer_init(p);
162 @@ -761,6 +762,9 @@ void br_port_flags_change(struct net_bri
164 if (mask & BR_NEIGH_SUPPRESS)
165 br_recalculate_neigh_suppress_enabled(br);
167 + if (mask & BR_OFFLOAD)
168 + br_offload_port_state(p);
171 bool br_port_flag_is_set(const struct net_device *dev, unsigned long flag)
172 --- a/net/bridge/br_input.c
173 +++ b/net/bridge/br_input.c
175 #include <linux/rculist.h>
176 #include "br_private.h"
177 #include "br_private_tunnel.h"
178 +#include "br_private_offload.h"
181 br_netif_receive_skb(struct net *net, struct sock *sk, struct sk_buff *skb)
182 @@ -189,6 +190,7 @@ int br_handle_frame_finish(struct net *n
184 br_forward(dst->dst, skb, local_rcv, false);
186 + br_offload_skb_disable(skb);
188 br_flood(br, skb, pkt_type, local_rcv, false);
190 @@ -322,6 +324,9 @@ static rx_handler_result_t br_handle_fra
191 memset(skb->cb, 0, sizeof(struct br_input_skb_cb));
193 p = br_port_get_rcu(skb->dev);
194 + if (br_offload_input(p, skb))
195 + return RX_HANDLER_CONSUMED;
197 if (p->flags & BR_VLAN_TUNNEL)
198 br_handle_ingress_vlan_tunnel(skb, p, nbp_vlan_group_rcu(p));
201 +++ b/net/bridge/br_offload.c
203 +// SPDX-License-Identifier: GPL-2.0-only
204 +#include <linux/kernel.h>
205 +#include <linux/workqueue.h>
206 +#include "br_private.h"
207 +#include "br_private_offload.h"
209 +static DEFINE_SPINLOCK(offload_lock);
211 +struct bridge_flow_key {
214 +#ifdef CONFIG_BRIDGE_VLAN_FILTERING
220 +struct bridge_flow {
221 + struct net_bridge_port *port;
222 + struct rhash_head node;
223 + struct bridge_flow_key key;
224 +#ifdef CONFIG_BRIDGE_VLAN_FILTERING
225 + bool vlan_out_present;
229 + unsigned long used;
230 + struct net_bridge_fdb_entry *fdb_in, *fdb_out;
231 + struct hlist_node fdb_list_in, fdb_list_out;
233 + struct rcu_head rcu;
236 +static const struct rhashtable_params flow_params = {
237 + .automatic_shrinking = true,
238 + .head_offset = offsetof(struct bridge_flow, node),
239 + .key_len = sizeof(struct bridge_flow_key),
240 + .key_offset = offsetof(struct bridge_flow, key),
243 +static struct kmem_cache *offload_cache __read_mostly;
246 +flow_rcu_free(struct rcu_head *head)
248 + struct bridge_flow *flow;
250 + flow = container_of(head, struct bridge_flow, rcu);
251 + kmem_cache_free(offload_cache, flow);
255 +__br_offload_flow_free(struct bridge_flow *flow)
258 + hlist_del(&flow->fdb_list_in);
259 + hlist_del(&flow->fdb_list_out);
261 + call_rcu(&flow->rcu, flow_rcu_free);
265 +br_offload_flow_free(struct bridge_flow *flow)
267 + if (rhashtable_remove_fast(&flow->port->offload.rht, &flow->node,
271 + __br_offload_flow_free(flow);
275 +br_offload_flow_fdb_refresh_time(struct bridge_flow *flow,
276 + struct net_bridge_fdb_entry *fdb)
278 + if (!time_after(flow->used, fdb->updated))
281 + fdb->updated = flow->used;
288 +br_offload_flow_refresh_time(struct bridge_flow *flow)
290 + br_offload_flow_fdb_refresh_time(flow, flow->fdb_in);
291 + br_offload_flow_fdb_refresh_time(flow, flow->fdb_out);
295 +br_offload_destroy_cb(void *ptr, void *arg)
297 + struct bridge_flow *flow = ptr;
299 + __br_offload_flow_free(flow);
303 +br_offload_need_gc(struct net_bridge_port *p)
305 + return (atomic_read(&p->offload.rht.nelems) +
306 + p->br->offload_cache_reserved) >= p->br->offload_cache_size;
310 +br_offload_gc_work(struct work_struct *work)
312 + struct rhashtable_iter hti;
313 + struct net_bridge_port *p;
314 + struct bridge_flow *gc_flow = NULL;
315 + struct bridge_flow *flow;
316 + unsigned long gc_used;
318 + p = container_of(work, struct net_bridge_port, offload.gc_work);
320 + if (!br_offload_need_gc(p))
323 + rhashtable_walk_enter(&p->offload.rht, &hti);
324 + rhashtable_walk_start(&hti);
325 + while ((flow = rhashtable_walk_next(&hti)) != NULL) {
326 + unsigned long used;
331 + used = READ_ONCE(flow->used);
335 + if (gc_flow && !time_before(used, gc_used))
341 + rhashtable_walk_stop(&hti);
342 + rhashtable_walk_exit(&hti);
347 + spin_lock_bh(&offload_lock);
348 + if (br_offload_need_gc(p) && gc_flow &&
349 + gc_flow->used == gc_used)
350 + br_offload_flow_free(gc_flow);
351 + if (p->offload.enabled && br_offload_need_gc(p))
352 + queue_work(system_long_wq, work);
353 + spin_unlock_bh(&offload_lock);
357 +void br_offload_port_state(struct net_bridge_port *p)
359 + struct net_bridge_port_offload *o = &p->offload;
360 + bool enabled = true;
361 + bool flush = false;
363 + if (p->state != BR_STATE_FORWARDING ||
364 + !(p->flags & BR_OFFLOAD))
367 + spin_lock_bh(&offload_lock);
368 + if (o->enabled == enabled)
372 + if (!o->gc_work.func)
373 + INIT_WORK(&o->gc_work, br_offload_gc_work);
374 + rhashtable_init(&o->rht, &flow_params);
377 + rhashtable_free_and_destroy(&o->rht, br_offload_destroy_cb, o);
380 + o->enabled = enabled;
383 + spin_unlock_bh(&offload_lock);
386 + flush_work(&o->gc_work);
389 +void br_offload_fdb_update(const struct net_bridge_fdb_entry *fdb)
391 + struct bridge_flow *f;
392 + struct hlist_node *tmp;
394 + spin_lock_bh(&offload_lock);
396 + hlist_for_each_entry_safe(f, tmp, &fdb->offload_in, fdb_list_in)
397 + br_offload_flow_free(f);
399 + hlist_for_each_entry_safe(f, tmp, &fdb->offload_out, fdb_list_out)
400 + br_offload_flow_free(f);
402 + spin_unlock_bh(&offload_lock);
406 +br_offload_prepare_key(struct net_bridge_port *p, struct bridge_flow_key *key,
407 + struct sk_buff *skb)
409 + memset(key, 0, sizeof(*key));
410 + memcpy(key, eth_hdr(skb), 2 * ETH_ALEN);
411 +#ifdef CONFIG_BRIDGE_VLAN_FILTERING
412 + if (!br_opt_get(p->br, BROPT_VLAN_ENABLED))
415 + if (!skb_vlan_tag_present(skb) || skb->vlan_proto != p->br->vlan_proto)
418 + key->vlan_present = true;
419 + key->vlan_tag = skb_vlan_tag_get_id(skb);
423 +void br_offload_output(struct sk_buff *skb)
425 + struct net_bridge_port_offload *o;
426 + struct br_input_skb_cb *cb = (struct br_input_skb_cb *)skb->cb;
427 + struct net_bridge_port *p, *inp;
428 + struct net_device *dev;
429 + struct net_bridge_fdb_entry *fdb_in, *fdb_out;
430 + struct net_bridge_vlan_group *vg;
431 + struct bridge_flow_key key;
432 + struct bridge_flow *flow;
440 + p = br_port_get_rcu(skb->dev);
448 + if (atomic_read(&p->offload.rht.nelems) >= p->br->offload_cache_size)
451 + dev = dev_get_by_index_rcu(dev_net(p->br->dev), cb->input_ifindex);
455 + inp = br_port_get_rcu(dev);
459 + vg = nbp_vlan_group_rcu(inp);
460 + vlan = cb->input_vlan_present ? cb->input_vlan_tag : br_get_pvid(vg);
461 + fdb_in = br_fdb_find_rcu(p->br, eth_hdr(skb)->h_source, vlan);
462 + if (!fdb_in || !fdb_in->dst)
465 + vg = nbp_vlan_group_rcu(p);
466 + vlan = skb_vlan_tag_present(skb) ? skb_vlan_tag_get_id(skb) : br_get_pvid(vg);
467 + fdb_out = br_fdb_find_rcu(p->br, eth_hdr(skb)->h_dest, vlan);
468 + if (!fdb_out || !fdb_out->dst)
471 + br_offload_prepare_key(p, &key, skb);
472 +#ifdef CONFIG_BRIDGE_VLAN_FILTERING
473 + key.vlan_present = cb->input_vlan_present;
474 + key.vlan_tag = cb->input_vlan_tag;
477 + flow = kmem_cache_alloc(offload_cache, GFP_ATOMIC);
479 + memcpy(&flow->key, &key, sizeof(key));
481 +#ifdef CONFIG_BRIDGE_VLAN_FILTERING
482 + flow->vlan_out_present = skb_vlan_tag_present(skb);
483 + flow->vlan_out = skb_vlan_tag_get(skb);
486 + flow->fdb_in = fdb_in;
487 + flow->fdb_out = fdb_out;
488 + flow->used = jiffies;
490 + spin_lock_bh(&offload_lock);
492 + atomic_read(&p->offload.rht.nelems) >= p->br->offload_cache_size ||
493 + rhashtable_insert_fast(&inp->offload.rht, &flow->node, flow_params)) {
494 + kmem_cache_free(offload_cache, flow);
498 + hlist_add_head(&flow->fdb_list_in, &fdb_in->offload_in);
499 + hlist_add_head(&flow->fdb_list_out, &fdb_out->offload_out);
501 + if (br_offload_need_gc(p))
502 + queue_work(system_long_wq, &p->offload.gc_work);
505 + spin_unlock_bh(&offload_lock);
511 +bool br_offload_input(struct net_bridge_port *p, struct sk_buff *skb)
513 + struct net_bridge_port_offload *o = &p->offload;
514 + struct br_input_skb_cb *cb = (struct br_input_skb_cb *)skb->cb;
515 + struct bridge_flow_key key;
516 + struct net_bridge_port *dst;
517 + struct bridge_flow *flow;
518 + unsigned long now = jiffies;
521 + if (skb->len < sizeof(key))
527 + if (is_multicast_ether_addr(eth_hdr(skb)->h_dest))
530 + br_offload_prepare_key(p, &key, skb);
533 + flow = rhashtable_lookup(&o->rht, &key, flow_params);
536 +#ifdef CONFIG_BRIDGE_VLAN_FILTERING
537 + cb->input_vlan_present = key.vlan_present != 0;
538 + cb->input_vlan_tag = key.vlan_tag;
540 + cb->input_ifindex = p->dev->ifindex;
544 + if (flow->fdb_in->dst != p)
547 + dst = flow->fdb_out->dst;
552 +#ifdef CONFIG_BRIDGE_VLAN_FILTERING
553 + if (!flow->vlan_out_present && key.vlan_present) {
554 + __vlan_hwaccel_clear_tag(skb);
555 + } else if (flow->vlan_out_present) {
556 + if (skb_vlan_tag_present(skb) &&
557 + skb->vlan_proto != p->br->vlan_proto) {
558 + /* Protocol-mismatch, empty out vlan_tci for new tag */
559 + skb_push(skb, ETH_HLEN);
560 + skb = vlan_insert_tag_set_proto(skb, skb->vlan_proto,
561 + skb_vlan_tag_get(skb));
562 + if (unlikely(!skb))
565 + skb_pull(skb, ETH_HLEN);
566 + skb_reset_mac_len(skb);
569 + __vlan_hwaccel_put_tag(skb, p->br->vlan_proto,
574 + skb->dev = dst->dev;
575 + skb_push(skb, ETH_HLEN);
577 + if (skb_warn_if_lro(skb) || !is_skb_forwardable(skb->dev, skb)) {
582 + if (now - flow->used >= HZ) {
584 + br_offload_flow_refresh_time(flow);
587 + skb_forward_csum(skb);
588 + dev_queue_xmit(skb);
596 +br_offload_check_gc(struct net_bridge *br)
598 + struct net_bridge_port *p;
600 + spin_lock_bh(&br->lock);
601 + list_for_each_entry(p, &br->port_list, list)
602 + if (br_offload_need_gc(p))
603 + queue_work(system_long_wq, &p->offload.gc_work);
604 + spin_unlock_bh(&br->lock);
608 +int br_offload_set_cache_size(struct net_bridge *br, unsigned long val,
609 + struct netlink_ext_ack *extack)
611 + br->offload_cache_size = val;
612 + br_offload_check_gc(br);
617 +int br_offload_set_cache_reserved(struct net_bridge *br, unsigned long val,
618 + struct netlink_ext_ack *extack)
620 + br->offload_cache_reserved = val;
621 + br_offload_check_gc(br);
626 +int __init br_offload_init(void)
628 + offload_cache = kmem_cache_create("bridge_offload_cache",
629 + sizeof(struct bridge_flow),
630 + 0, SLAB_HWCACHE_ALIGN, NULL);
631 + if (!offload_cache)
637 +void br_offload_fini(void)
639 + kmem_cache_destroy(offload_cache);
641 --- a/net/bridge/br_private.h
642 +++ b/net/bridge/br_private.h
643 @@ -271,7 +271,13 @@ struct net_bridge_fdb_entry {
644 unsigned long updated ____cacheline_aligned_in_smp;
647 - struct rcu_head rcu;
650 + struct hlist_head offload_in;
651 + struct hlist_head offload_out;
653 + struct rcu_head rcu;
657 struct net_bridge_fdb_flush_desc {
658 @@ -353,6 +359,12 @@ struct net_bridge_mdb_entry {
662 +struct net_bridge_port_offload {
663 + struct rhashtable rht;
664 + struct work_struct gc_work;
668 struct net_bridge_port {
669 struct net_bridge *br;
670 struct net_device *dev;
671 @@ -414,6 +426,7 @@ struct net_bridge_port {
672 u16 backup_redirected_cnt;
674 struct bridge_stp_xstats stp_xstats;
675 + struct net_bridge_port_offload offload;
678 #define kobj_to_brport(obj) container_of(obj, struct net_bridge_port, kobj)
679 @@ -531,6 +544,9 @@ struct net_bridge {
680 struct kobject *ifobj;
683 + u32 offload_cache_size;
684 + u32 offload_cache_reserved;
686 #ifdef CONFIG_NET_SWITCHDEV
687 /* Counter used to make sure that hardware domains get unique
688 * identifiers in case a bridge spans multiple switchdev instances.
689 @@ -565,6 +581,10 @@ struct br_input_skb_cb {
690 #ifdef CONFIG_NETFILTER_FAMILY_BRIDGE
691 u8 br_netfilter_broute:1;
694 + u8 input_vlan_present:1;
695 + u16 input_vlan_tag;
698 #ifdef CONFIG_NET_SWITCHDEV
699 /* Set if TX data plane offloading is used towards at least one
701 +++ b/net/bridge/br_private_offload.h
703 +#ifndef __BR_OFFLOAD_H
704 +#define __BR_OFFLOAD_H
706 +bool br_offload_input(struct net_bridge_port *p, struct sk_buff *skb);
707 +void br_offload_output(struct sk_buff *skb);
708 +void br_offload_port_state(struct net_bridge_port *p);
709 +void br_offload_fdb_update(const struct net_bridge_fdb_entry *fdb);
710 +int br_offload_init(void);
711 +void br_offload_fini(void);
712 +int br_offload_set_cache_size(struct net_bridge *br, unsigned long val,
713 + struct netlink_ext_ack *extack);
714 +int br_offload_set_cache_reserved(struct net_bridge *br, unsigned long val,
715 + struct netlink_ext_ack *extack);
717 +static inline void br_offload_skb_disable(struct sk_buff *skb)
719 + struct br_input_skb_cb *cb = (struct br_input_skb_cb *)skb->cb;
726 --- a/net/bridge/br_stp.c
727 +++ b/net/bridge/br_stp.c
730 #include "br_private.h"
731 #include "br_private_stp.h"
732 +#include "br_private_offload.h"
734 /* since time values in bpdu are in jiffies and then scaled (1/256)
735 * before sending, make sure that is at least one STP tick.
736 @@ -58,6 +59,8 @@ void br_set_state(struct net_bridge_port
737 (unsigned int) p->port_no, p->dev->name,
738 br_port_state_names[p->state]);
740 + br_offload_port_state(p);
742 if (p->br->stp_enabled == BR_KERNEL_STP) {
744 case BR_STATE_BLOCKING:
745 --- a/net/bridge/br_sysfs_br.c
746 +++ b/net/bridge/br_sysfs_br.c
748 #include <linux/sched/signal.h>
750 #include "br_private.h"
751 +#include "br_private_offload.h"
753 /* IMPORTANT: new bridge options must be added with netlink support only
754 * please do not add new sysfs entries
755 @@ -933,6 +934,38 @@ static ssize_t vlan_stats_per_port_store
756 static DEVICE_ATTR_RW(vlan_stats_per_port);
759 +static ssize_t offload_cache_size_show(struct device *d,
760 + struct device_attribute *attr,
763 + struct net_bridge *br = to_bridge(d);
764 + return sprintf(buf, "%u\n", br->offload_cache_size);
767 +static ssize_t offload_cache_size_store(struct device *d,
768 + struct device_attribute *attr,
769 + const char *buf, size_t len)
771 + return store_bridge_parm(d, buf, len, br_offload_set_cache_size);
773 +static DEVICE_ATTR_RW(offload_cache_size);
775 +static ssize_t offload_cache_reserved_show(struct device *d,
776 + struct device_attribute *attr,
779 + struct net_bridge *br = to_bridge(d);
780 + return sprintf(buf, "%u\n", br->offload_cache_reserved);
783 +static ssize_t offload_cache_reserved_store(struct device *d,
784 + struct device_attribute *attr,
785 + const char *buf, size_t len)
787 + return store_bridge_parm(d, buf, len, br_offload_set_cache_reserved);
789 +static DEVICE_ATTR_RW(offload_cache_reserved);
791 static struct attribute *bridge_attrs[] = {
792 &dev_attr_forward_delay.attr,
793 &dev_attr_hello_time.attr,
794 @@ -987,6 +1020,8 @@ static struct attribute *bridge_attrs[]
795 &dev_attr_vlan_stats_enabled.attr,
796 &dev_attr_vlan_stats_per_port.attr,
798 + &dev_attr_offload_cache_size.attr,
799 + &dev_attr_offload_cache_reserved.attr,
803 --- a/net/bridge/br_sysfs_if.c
804 +++ b/net/bridge/br_sysfs_if.c
805 @@ -241,6 +241,7 @@ BRPORT_ATTR_FLAG(broadcast_flood, BR_BCA
806 BRPORT_ATTR_FLAG(neigh_suppress, BR_NEIGH_SUPPRESS);
807 BRPORT_ATTR_FLAG(isolated, BR_ISOLATED);
808 BRPORT_ATTR_FLAG(bpdu_filter, BR_BPDU_FILTER);
809 +BRPORT_ATTR_FLAG(offload, BR_OFFLOAD);
811 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
812 static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
813 @@ -295,6 +296,7 @@ static const struct brport_attribute *br
814 &brport_attr_isolated,
815 &brport_attr_bpdu_filter,
816 &brport_attr_backup_port,
817 + &brport_attr_offload,
821 --- a/net/bridge/br_vlan_tunnel.c
822 +++ b/net/bridge/br_vlan_tunnel.c
825 #include "br_private.h"
826 #include "br_private_tunnel.h"
827 +#include "br_private_offload.h"
829 static inline int br_vlan_tunid_cmp(struct rhashtable_compare_arg *arg,
831 @@ -180,6 +181,7 @@ void br_handle_ingress_vlan_tunnel(struc
834 __vlan_hwaccel_put_tag(skb, p->br->vlan_proto, vlan->vid);
835 + br_offload_skb_disable(skb);
838 int br_handle_egress_vlan_tunnel(struct sk_buff *skb,
839 @@ -201,6 +203,7 @@ int br_handle_egress_vlan_tunnel(struct
843 + br_offload_skb_disable(skb);
844 tunnel_dst = rcu_dereference(vlan->tinfo.tunnel_dst);
845 if (tunnel_dst && dst_hold_safe(&tunnel_dst->dst))
846 skb_dst_set(skb, &tunnel_dst->dst);