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 <yuvalm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
bc67a0daf8
commit
54c4cad97b
@ -5391,7 +5391,9 @@ static int mlxsw_sp_router_fibmr_add(struct mlxsw_sp *mlxsw_sp,
|
|||||||
if (IS_ERR(vr))
|
if (IS_ERR(vr))
|
||||||
return PTR_ERR(vr);
|
return PTR_ERR(vr);
|
||||||
|
|
||||||
return mlxsw_sp_mr_route4_add(vr->mr4_table, men_info->mfc, replace);
|
return mlxsw_sp_mr_route4_add(vr->mr4_table,
|
||||||
|
(struct mfc_cache *) men_info->mfc,
|
||||||
|
replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mlxsw_sp_router_fibmr_del(struct mlxsw_sp *mlxsw_sp,
|
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,
|
|||||||
if (WARN_ON(!vr))
|
if (WARN_ON(!vr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mlxsw_sp_mr_route4_del(vr->mr4_table, men_info->mfc);
|
mlxsw_sp_mr_route4_del(vr->mr4_table,
|
||||||
|
(struct mfc_cache *) men_info->mfc);
|
||||||
mlxsw_sp_vr_put(mlxsw_sp, vr);
|
mlxsw_sp_vr_put(mlxsw_sp, vr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5682,11 +5685,11 @@ static void mlxsw_sp_router_fibmr_event_work(struct work_struct *work)
|
|||||||
replace);
|
replace);
|
||||||
if (err)
|
if (err)
|
||||||
mlxsw_sp_router_fib_abort(mlxsw_sp);
|
mlxsw_sp_router_fib_abort(mlxsw_sp);
|
||||||
ipmr_cache_put(fib_work->men_info.mfc);
|
ipmr_cache_put((struct mfc_cache *) fib_work->men_info.mfc);
|
||||||
break;
|
break;
|
||||||
case FIB_EVENT_ENTRY_DEL:
|
case FIB_EVENT_ENTRY_DEL:
|
||||||
mlxsw_sp_router_fibmr_del(mlxsw_sp, &fib_work->men_info);
|
mlxsw_sp_router_fibmr_del(mlxsw_sp, &fib_work->men_info);
|
||||||
ipmr_cache_put(fib_work->men_info.mfc);
|
ipmr_cache_put((struct mfc_cache *) fib_work->men_info.mfc);
|
||||||
break;
|
break;
|
||||||
case FIB_EVENT_VIF_ADD:
|
case FIB_EVENT_VIF_ADD:
|
||||||
err = mlxsw_sp_router_fibmr_vif_add(mlxsw_sp,
|
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,
|
|||||||
case FIB_EVENT_ENTRY_ADD: /* fall through */
|
case FIB_EVENT_ENTRY_ADD: /* fall through */
|
||||||
case FIB_EVENT_ENTRY_DEL:
|
case FIB_EVENT_ENTRY_DEL:
|
||||||
memcpy(&fib_work->men_info, info, sizeof(fib_work->men_info));
|
memcpy(&fib_work->men_info, info, sizeof(fib_work->men_info));
|
||||||
ipmr_cache_hold(fib_work->men_info.mfc);
|
ipmr_cache_hold((struct mfc_cache *) fib_work->men_info.mfc);
|
||||||
break;
|
break;
|
||||||
case FIB_EVENT_VIF_ADD: /* fall through */
|
case FIB_EVENT_VIF_ADD: /* fall through */
|
||||||
case FIB_EVENT_VIF_DEL:
|
case FIB_EVENT_VIF_DEL:
|
||||||
|
@ -80,12 +80,6 @@ struct mfc_cache {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mfc_entry_notifier_info {
|
|
||||||
struct fib_notifier_info info;
|
|
||||||
struct mfc_cache *mfc;
|
|
||||||
u32 tb_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct rtmsg;
|
struct rtmsg;
|
||||||
int ipmr_get_route(struct net *net, struct sk_buff *skb,
|
int ipmr_get_route(struct net *net, struct sk_buff *skb,
|
||||||
__be32 saddr, __be32 daddr,
|
__be32 saddr, __be32 daddr,
|
||||||
|
@ -152,6 +152,50 @@ struct mr_mfc {
|
|||||||
struct rcu_head rcu;
|
struct rcu_head rcu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct mfc_entry_notifier_info {
|
||||||
|
struct fib_notifier_info info;
|
||||||
|
struct mr_mfc *mfc;
|
||||||
|
u32 tb_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline int mr_call_mfc_notifier(struct notifier_block *nb,
|
||||||
|
struct net *net,
|
||||||
|
unsigned short family,
|
||||||
|
enum fib_event_type event_type,
|
||||||
|
struct mr_mfc *mfc, u32 tb_id)
|
||||||
|
{
|
||||||
|
struct mfc_entry_notifier_info info = {
|
||||||
|
.info = {
|
||||||
|
.family = family,
|
||||||
|
.net = net,
|
||||||
|
},
|
||||||
|
.mfc = mfc,
|
||||||
|
.tb_id = tb_id
|
||||||
|
};
|
||||||
|
|
||||||
|
return call_fib_notifier(nb, net, event_type, &info.info);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int mr_call_mfc_notifiers(struct net *net,
|
||||||
|
unsigned short family,
|
||||||
|
enum fib_event_type event_type,
|
||||||
|
struct mr_mfc *mfc, u32 tb_id,
|
||||||
|
unsigned int *ipmr_seq)
|
||||||
|
{
|
||||||
|
struct mfc_entry_notifier_info info = {
|
||||||
|
.info = {
|
||||||
|
.family = family,
|
||||||
|
.net = net,
|
||||||
|
},
|
||||||
|
.mfc = mfc,
|
||||||
|
.tb_id = tb_id
|
||||||
|
};
|
||||||
|
|
||||||
|
ASSERT_RTNL();
|
||||||
|
(*ipmr_seq)++;
|
||||||
|
return call_fib_notifiers(net, event_type, &info.info);
|
||||||
|
}
|
||||||
|
|
||||||
struct mr_table;
|
struct mr_table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -669,34 +669,16 @@ static int call_ipmr_mfc_entry_notifier(struct notifier_block *nb,
|
|||||||
enum fib_event_type event_type,
|
enum fib_event_type event_type,
|
||||||
struct mfc_cache *mfc, u32 tb_id)
|
struct mfc_cache *mfc, u32 tb_id)
|
||||||
{
|
{
|
||||||
struct mfc_entry_notifier_info info = {
|
return mr_call_mfc_notifier(nb, net, RTNL_FAMILY_IPMR,
|
||||||
.info = {
|
event_type, &mfc->_c, tb_id);
|
||||||
.family = RTNL_FAMILY_IPMR,
|
|
||||||
.net = net,
|
|
||||||
},
|
|
||||||
.mfc = mfc,
|
|
||||||
.tb_id = tb_id
|
|
||||||
};
|
|
||||||
|
|
||||||
return call_fib_notifier(nb, net, event_type, &info.info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int call_ipmr_mfc_entry_notifiers(struct net *net,
|
static int call_ipmr_mfc_entry_notifiers(struct net *net,
|
||||||
enum fib_event_type event_type,
|
enum fib_event_type event_type,
|
||||||
struct mfc_cache *mfc, u32 tb_id)
|
struct mfc_cache *mfc, u32 tb_id)
|
||||||
{
|
{
|
||||||
struct mfc_entry_notifier_info info = {
|
return mr_call_mfc_notifiers(net, RTNL_FAMILY_IPMR, event_type,
|
||||||
.info = {
|
&mfc->_c, tb_id, &net->ipv4.ipmr_seq);
|
||||||
.family = RTNL_FAMILY_IPMR,
|
|
||||||
.net = net,
|
|
||||||
},
|
|
||||||
.mfc = mfc,
|
|
||||||
.tb_id = tb_id
|
|
||||||
};
|
|
||||||
|
|
||||||
ASSERT_RTNL();
|
|
||||||
net->ipv4.ipmr_seq++;
|
|
||||||
return call_fib_notifiers(net, event_type, &info.info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user