Merge tag 'sound-fix-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[linux-2.6-block.git] / net / bridge / br_nf_core.c
CommitLineData
2874c5fd 1// SPDX-License-Identifier: GPL-2.0-or-later
34666d46
PNA
2/*
3 * Handle firewalling core
4 * Linux ethernet bridge
5 *
6 * Authors:
7 * Lennert Buytenhek <buytenh@gnu.org>
8 * Bart De Schuymer <bdschuym@pandora.be>
9 *
34666d46
PNA
10 * Lennert dedicates this file to Kerstin Wurdinger.
11 */
12
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>
18
19#include "br_private.h"
20#ifdef CONFIG_SYSCTL
21#include <linux/sysctl.h>
22#endif
23
24static void fake_update_pmtu(struct dst_entry *dst, struct sock *sk,
25 struct sk_buff *skb, u32 mtu)
26{
27}
28
29static void fake_redirect(struct dst_entry *dst, struct sock *sk,
30 struct sk_buff *skb)
31{
32}
33
34static u32 *fake_cow_metrics(struct dst_entry *dst, unsigned long old)
35{
36 return NULL;
37}
38
39static struct neighbour *fake_neigh_lookup(const struct dst_entry *dst,
40 struct sk_buff *skb,
41 const void *daddr)
42{
43 return NULL;
44}
45
46static unsigned int fake_mtu(const struct dst_entry *dst)
47{
48 return dst->dev->mtu;
49}
50
51static struct dst_ops fake_dst_ops = {
52 .family = AF_INET,
34666d46
PNA
53 .update_pmtu = fake_update_pmtu,
54 .redirect = fake_redirect,
55 .cow_metrics = fake_cow_metrics,
56 .neigh_lookup = fake_neigh_lookup,
57 .mtu = fake_mtu,
58};
59
60/*
61 * Initialize bogus route table used to keep netfilter happy.
62 * Currently, we fill in the PMTU entry because netfilter
63 * refragmentation needs it, and the rt_flags entry because
64 * ipt_REJECT needs it. Future netfilter modules might
65 * require us to fill additional fields.
66 */
67static const u32 br_dst_default_metrics[RTAX_MAX] = {
68 [RTAX_MTU - 1] = 1500,
69};
70
71void br_netfilter_rtable_init(struct net_bridge *br)
72{
73 struct rtable *rt = &br->fake_rtable;
74
75 atomic_set(&rt->dst.__refcnt, 1);
76 rt->dst.dev = br->dev;
34666d46
PNA
77 dst_init_metrics(&rt->dst, br_dst_default_metrics, true);
78 rt->dst.flags = DST_NOXFRM | DST_FAKE_RTABLE;
79 rt->dst.ops = &fake_dst_ops;
80}
81
82int __init br_nf_core_init(void)
83{
84 return dst_entries_init(&fake_dst_ops);
85}
86
87void br_nf_core_fini(void)
88{
89 dst_entries_destroy(&fake_dst_ops);
90}