1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Handle firewalling core
4 * Linux ethernet bridge
7 * Lennert Buytenhek <buytenh@gnu.org>
8 * Bart De Schuymer <bdschuym@pandora.be>
10 * Lennert dedicates this file to Kerstin Wurdinger.
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/in_route.h>
16 #include <linux/inetdevice.h>
17 #include <net/route.h>
19 #include "br_private.h"
21 #include <linux/sysctl.h>
24 static void fake_update_pmtu(struct dst_entry
*dst
, struct sock
*sk
,
25 struct sk_buff
*skb
, u32 mtu
,
30 static void fake_redirect(struct dst_entry
*dst
, struct sock
*sk
,
35 static u32
*fake_cow_metrics(struct dst_entry
*dst
, unsigned long old
)
40 static struct neighbour
*fake_neigh_lookup(const struct dst_entry
*dst
,
47 static unsigned int fake_mtu(const struct dst_entry
*dst
)
52 static struct dst_ops fake_dst_ops
= {
54 .update_pmtu
= fake_update_pmtu
,
55 .redirect
= fake_redirect
,
56 .cow_metrics
= fake_cow_metrics
,
57 .neigh_lookup
= fake_neigh_lookup
,
62 * Initialize bogus route table used to keep netfilter happy.
63 * Currently, we fill in the PMTU entry because netfilter
64 * refragmentation needs it, and the rt_flags entry because
65 * ipt_REJECT needs it. Future netfilter modules might
66 * require us to fill additional fields.
68 static const u32 br_dst_default_metrics
[RTAX_MAX
] = {
69 [RTAX_MTU
- 1] = 1500,
72 void br_netfilter_rtable_init(struct net_bridge
*br
)
74 struct rtable
*rt
= &br
->fake_rtable
;
76 atomic_set(&rt
->dst
.__refcnt
, 1);
77 rt
->dst
.dev
= br
->dev
;
78 dst_init_metrics(&rt
->dst
, br_dst_default_metrics
, true);
79 rt
->dst
.flags
= DST_NOXFRM
| DST_FAKE_RTABLE
;
80 rt
->dst
.ops
= &fake_dst_ops
;
83 int __init
br_nf_core_init(void)
85 return dst_entries_init(&fake_dst_ops
);
88 void br_nf_core_fini(void)
90 dst_entries_destroy(&fake_dst_ops
);