Skip to content

Commit bc67a0d

Browse files
Yuval Mintzdavem330
authored andcommitted
ipmr: Make vif fib notifiers common
The fib-notifiers are tightly coupled with the vif_device which is already common. Move the notifier struct definition and helpers to the common file; Currently they're only used by ipmr. Signed-off-by: Yuval Mintz <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 02a21de commit bc67a0d

File tree

3 files changed

+58
-34
lines changed

3 files changed

+58
-34
lines changed

include/linux/mroute.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ static inline bool ipmr_rule_default(const struct fib_rule *rule)
5555
}
5656
#endif
5757

58-
struct vif_entry_notifier_info {
59-
struct fib_notifier_info info;
60-
struct net_device *dev;
61-
vifi_t vif_index;
62-
unsigned short vif_flags;
63-
u32 tb_id;
64-
};
65-
6658
#define VIFF_STATIC 0x8000
6759

6860
struct mfc_cache_cmp_arg {

include/linux/mroute_base.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/spinlock.h>
77
#include <net/net_namespace.h>
88
#include <net/sock.h>
9+
#include <net/fib_notifier.h>
910

1011
/**
1112
* struct vif_device - interface representor for multicast routing
@@ -36,6 +37,58 @@ struct vif_device {
3637
__be32 local, remote;
3738
};
3839

40+
struct vif_entry_notifier_info {
41+
struct fib_notifier_info info;
42+
struct net_device *dev;
43+
unsigned short vif_index;
44+
unsigned short vif_flags;
45+
u32 tb_id;
46+
};
47+
48+
static inline int mr_call_vif_notifier(struct notifier_block *nb,
49+
struct net *net,
50+
unsigned short family,
51+
enum fib_event_type event_type,
52+
struct vif_device *vif,
53+
unsigned short vif_index, u32 tb_id)
54+
{
55+
struct vif_entry_notifier_info info = {
56+
.info = {
57+
.family = family,
58+
.net = net,
59+
},
60+
.dev = vif->dev,
61+
.vif_index = vif_index,
62+
.vif_flags = vif->flags,
63+
.tb_id = tb_id,
64+
};
65+
66+
return call_fib_notifier(nb, net, event_type, &info.info);
67+
}
68+
69+
static inline int mr_call_vif_notifiers(struct net *net,
70+
unsigned short family,
71+
enum fib_event_type event_type,
72+
struct vif_device *vif,
73+
unsigned short vif_index, u32 tb_id,
74+
unsigned int *ipmr_seq)
75+
{
76+
struct vif_entry_notifier_info info = {
77+
.info = {
78+
.family = family,
79+
.net = net,
80+
},
81+
.dev = vif->dev,
82+
.vif_index = vif_index,
83+
.vif_flags = vif->flags,
84+
.tb_id = tb_id,
85+
};
86+
87+
ASSERT_RTNL();
88+
(*ipmr_seq)++;
89+
return call_fib_notifiers(net, event_type, &info.info);
90+
}
91+
3992
#ifndef MAXVIFS
4093
/* This one is nasty; value is defined in uapi using different symbols for
4194
* mroute and morute6 but both map into same 32.

net/ipv4/ipmr.c

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -650,39 +650,18 @@ static int call_ipmr_vif_entry_notifier(struct notifier_block *nb,
650650
struct vif_device *vif,
651651
vifi_t vif_index, u32 tb_id)
652652
{
653-
struct vif_entry_notifier_info info = {
654-
.info = {
655-
.family = RTNL_FAMILY_IPMR,
656-
.net = net,
657-
},
658-
.dev = vif->dev,
659-
.vif_index = vif_index,
660-
.vif_flags = vif->flags,
661-
.tb_id = tb_id,
662-
};
663-
664-
return call_fib_notifier(nb, net, event_type, &info.info);
653+
return mr_call_vif_notifier(nb, net, RTNL_FAMILY_IPMR, event_type,
654+
vif, vif_index, tb_id);
665655
}
666656

667657
static int call_ipmr_vif_entry_notifiers(struct net *net,
668658
enum fib_event_type event_type,
669659
struct vif_device *vif,
670660
vifi_t vif_index, u32 tb_id)
671661
{
672-
struct vif_entry_notifier_info info = {
673-
.info = {
674-
.family = RTNL_FAMILY_IPMR,
675-
.net = net,
676-
},
677-
.dev = vif->dev,
678-
.vif_index = vif_index,
679-
.vif_flags = vif->flags,
680-
.tb_id = tb_id,
681-
};
682-
683-
ASSERT_RTNL();
684-
net->ipv4.ipmr_seq++;
685-
return call_fib_notifiers(net, event_type, &info.info);
662+
return mr_call_vif_notifiers(net, RTNL_FAMILY_IPMR, event_type,
663+
vif, vif_index, tb_id,
664+
&net->ipv4.ipmr_seq);
686665
}
687666

688667
static int call_ipmr_mfc_entry_notifier(struct notifier_block *nb,

0 commit comments

Comments
 (0)