Skip to content

Commit 3c75f9b

Browse files
dsaherndavem330
authored andcommitted
spectrum: Convert fib event handlers to use container_of on info arg
Use container_of to convert the generic fib_notifier_info into the event specific data structure. Signed-off-by: David Ahern <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ba233b3 commit 3c75f9b

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,25 +5209,35 @@ static void mlxsw_sp_router_fibmr_event_work(struct work_struct *work)
52095209
static void mlxsw_sp_router_fib4_event(struct mlxsw_sp_fib_event_work *fib_work,
52105210
struct fib_notifier_info *info)
52115211
{
5212+
struct fib_entry_notifier_info *fen_info;
5213+
struct fib_rule_notifier_info *fr_info;
5214+
struct fib_nh_notifier_info *fnh_info;
5215+
52125216
switch (fib_work->event) {
52135217
case FIB_EVENT_ENTRY_REPLACE: /* fall through */
52145218
case FIB_EVENT_ENTRY_APPEND: /* fall through */
52155219
case FIB_EVENT_ENTRY_ADD: /* fall through */
52165220
case FIB_EVENT_ENTRY_DEL:
5217-
memcpy(&fib_work->fen_info, info, sizeof(fib_work->fen_info));
5218-
/* Take referece on fib_info to prevent it from being
5221+
fen_info = container_of(info, struct fib_entry_notifier_info,
5222+
info);
5223+
fib_work->fen_info = *fen_info;
5224+
/* Take reference on fib_info to prevent it from being
52195225
* freed while work is queued. Release it afterwards.
52205226
*/
52215227
fib_info_hold(fib_work->fen_info.fi);
52225228
break;
52235229
case FIB_EVENT_RULE_ADD: /* fall through */
52245230
case FIB_EVENT_RULE_DEL:
5225-
memcpy(&fib_work->fr_info, info, sizeof(fib_work->fr_info));
5231+
fr_info = container_of(info, struct fib_rule_notifier_info,
5232+
info);
5233+
fib_work->fr_info = *fr_info;
52265234
fib_rule_get(fib_work->fr_info.rule);
52275235
break;
52285236
case FIB_EVENT_NH_ADD: /* fall through */
52295237
case FIB_EVENT_NH_DEL:
5230-
memcpy(&fib_work->fnh_info, info, sizeof(fib_work->fnh_info));
5238+
fnh_info = container_of(info, struct fib_nh_notifier_info,
5239+
info);
5240+
fib_work->fnh_info = *fnh_info;
52315241
fib_info_hold(fib_work->fnh_info.fib_nh->nh_parent);
52325242
break;
52335243
}
@@ -5236,16 +5246,23 @@ static void mlxsw_sp_router_fib4_event(struct mlxsw_sp_fib_event_work *fib_work,
52365246
static void mlxsw_sp_router_fib6_event(struct mlxsw_sp_fib_event_work *fib_work,
52375247
struct fib_notifier_info *info)
52385248
{
5249+
struct fib6_entry_notifier_info *fen6_info;
5250+
struct fib_rule_notifier_info *fr_info;
5251+
52395252
switch (fib_work->event) {
52405253
case FIB_EVENT_ENTRY_REPLACE: /* fall through */
52415254
case FIB_EVENT_ENTRY_ADD: /* fall through */
52425255
case FIB_EVENT_ENTRY_DEL:
5243-
memcpy(&fib_work->fen6_info, info, sizeof(fib_work->fen6_info));
5256+
fen6_info = container_of(info, struct fib6_entry_notifier_info,
5257+
info);
5258+
fib_work->fen6_info = *fen6_info;
52445259
rt6_hold(fib_work->fen6_info.rt);
52455260
break;
52465261
case FIB_EVENT_RULE_ADD: /* fall through */
52475262
case FIB_EVENT_RULE_DEL:
5248-
memcpy(&fib_work->fr_info, info, sizeof(fib_work->fr_info));
5263+
fr_info = container_of(info, struct fib_rule_notifier_info,
5264+
info);
5265+
fib_work->fr_info = *fr_info;
52495266
fib_rule_get(fib_work->fr_info.rule);
52505267
break;
52515268
}

0 commit comments

Comments
 (0)