Skip to content

Commit 54c4cad

Browse files
Yuval Mintzdavem330
authored andcommitted
ipmr: Make MFC fib notifiers common
Like vif notifications, move the notifier struct for MFC as well as its helpers into a 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 bc67a0d commit 54c4cad

File tree

4 files changed

+56
-33
lines changed

4 files changed

+56
-33
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5391,7 +5391,9 @@ static int mlxsw_sp_router_fibmr_add(struct mlxsw_sp *mlxsw_sp,
53915391
if (IS_ERR(vr))
53925392
return PTR_ERR(vr);
53935393

5394-
return mlxsw_sp_mr_route4_add(vr->mr4_table, men_info->mfc, replace);
5394+
return mlxsw_sp_mr_route4_add(vr->mr4_table,
5395+
(struct mfc_cache *) men_info->mfc,
5396+
replace);
53955397
}
53965398

53975399
static void mlxsw_sp_router_fibmr_del(struct mlxsw_sp *mlxsw_sp,
@@ -5406,7 +5408,8 @@ static void mlxsw_sp_router_fibmr_del(struct mlxsw_sp *mlxsw_sp,
54065408
if (WARN_ON(!vr))
54075409
return;
54085410

5409-
mlxsw_sp_mr_route4_del(vr->mr4_table, men_info->mfc);
5411+
mlxsw_sp_mr_route4_del(vr->mr4_table,
5412+
(struct mfc_cache *) men_info->mfc);
54105413
mlxsw_sp_vr_put(mlxsw_sp, vr);
54115414
}
54125415

@@ -5682,11 +5685,11 @@ static void mlxsw_sp_router_fibmr_event_work(struct work_struct *work)
56825685
replace);
56835686
if (err)
56845687
mlxsw_sp_router_fib_abort(mlxsw_sp);
5685-
ipmr_cache_put(fib_work->men_info.mfc);
5688+
ipmr_cache_put((struct mfc_cache *) fib_work->men_info.mfc);
56865689
break;
56875690
case FIB_EVENT_ENTRY_DEL:
56885691
mlxsw_sp_router_fibmr_del(mlxsw_sp, &fib_work->men_info);
5689-
ipmr_cache_put(fib_work->men_info.mfc);
5692+
ipmr_cache_put((struct mfc_cache *) fib_work->men_info.mfc);
56905693
break;
56915694
case FIB_EVENT_VIF_ADD:
56925695
err = mlxsw_sp_router_fibmr_vif_add(mlxsw_sp,
@@ -5766,7 +5769,7 @@ mlxsw_sp_router_fibmr_event(struct mlxsw_sp_fib_event_work *fib_work,
57665769
case FIB_EVENT_ENTRY_ADD: /* fall through */
57675770
case FIB_EVENT_ENTRY_DEL:
57685771
memcpy(&fib_work->men_info, info, sizeof(fib_work->men_info));
5769-
ipmr_cache_hold(fib_work->men_info.mfc);
5772+
ipmr_cache_hold((struct mfc_cache *) fib_work->men_info.mfc);
57705773
break;
57715774
case FIB_EVENT_VIF_ADD: /* fall through */
57725775
case FIB_EVENT_VIF_DEL:

include/linux/mroute.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ struct mfc_cache {
8080
};
8181
};
8282

83-
struct mfc_entry_notifier_info {
84-
struct fib_notifier_info info;
85-
struct mfc_cache *mfc;
86-
u32 tb_id;
87-
};
88-
8983
struct rtmsg;
9084
int ipmr_get_route(struct net *net, struct sk_buff *skb,
9185
__be32 saddr, __be32 daddr,

include/linux/mroute_base.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,50 @@ struct mr_mfc {
152152
struct rcu_head rcu;
153153
};
154154

155+
struct mfc_entry_notifier_info {
156+
struct fib_notifier_info info;
157+
struct mr_mfc *mfc;
158+
u32 tb_id;
159+
};
160+
161+
static inline int mr_call_mfc_notifier(struct notifier_block *nb,
162+
struct net *net,
163+
unsigned short family,
164+
enum fib_event_type event_type,
165+
struct mr_mfc *mfc, u32 tb_id)
166+
{
167+
struct mfc_entry_notifier_info info = {
168+
.info = {
169+
.family = family,
170+
.net = net,
171+
},
172+
.mfc = mfc,
173+
.tb_id = tb_id
174+
};
175+
176+
return call_fib_notifier(nb, net, event_type, &info.info);
177+
}
178+
179+
static inline int mr_call_mfc_notifiers(struct net *net,
180+
unsigned short family,
181+
enum fib_event_type event_type,
182+
struct mr_mfc *mfc, u32 tb_id,
183+
unsigned int *ipmr_seq)
184+
{
185+
struct mfc_entry_notifier_info info = {
186+
.info = {
187+
.family = family,
188+
.net = net,
189+
},
190+
.mfc = mfc,
191+
.tb_id = tb_id
192+
};
193+
194+
ASSERT_RTNL();
195+
(*ipmr_seq)++;
196+
return call_fib_notifiers(net, event_type, &info.info);
197+
}
198+
155199
struct mr_table;
156200

157201
/**

net/ipv4/ipmr.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -669,34 +669,16 @@ static int call_ipmr_mfc_entry_notifier(struct notifier_block *nb,
669669
enum fib_event_type event_type,
670670
struct mfc_cache *mfc, u32 tb_id)
671671
{
672-
struct mfc_entry_notifier_info info = {
673-
.info = {
674-
.family = RTNL_FAMILY_IPMR,
675-
.net = net,
676-
},
677-
.mfc = mfc,
678-
.tb_id = tb_id
679-
};
680-
681-
return call_fib_notifier(nb, net, event_type, &info.info);
672+
return mr_call_mfc_notifier(nb, net, RTNL_FAMILY_IPMR,
673+
event_type, &mfc->_c, tb_id);
682674
}
683675

684676
static int call_ipmr_mfc_entry_notifiers(struct net *net,
685677
enum fib_event_type event_type,
686678
struct mfc_cache *mfc, u32 tb_id)
687679
{
688-
struct mfc_entry_notifier_info info = {
689-
.info = {
690-
.family = RTNL_FAMILY_IPMR,
691-
.net = net,
692-
},
693-
.mfc = mfc,
694-
.tb_id = tb_id
695-
};
696-
697-
ASSERT_RTNL();
698-
net->ipv4.ipmr_seq++;
699-
return call_fib_notifiers(net, event_type, &info.info);
680+
return mr_call_mfc_notifiers(net, RTNL_FAMILY_IPMR, event_type,
681+
&mfc->_c, tb_id, &net->ipv4.ipmr_seq);
700682
}
701683

702684
/**

0 commit comments

Comments
 (0)