* [PATCH net-next] spectrum: Convert fib event handlers to use container_of on info arg
@ 2017-10-18 22:01 David Ahern
2017-10-19 7:09 ` Jiri Pirko
2017-10-21 0:45 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: David Ahern @ 2017-10-18 22:01 UTC (permalink / raw)
To: netdev; +Cc: jiri, idosch, David Ahern
Use container_of to convert the generic fib_notifier_info into
the event specific data structure.
Signed-off-by: David Ahern <dsahern@gmail.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
---
.../net/ethernet/mellanox/mlxsw/spectrum_router.c | 29 +++++++++++++++++-----
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 2420f69797a9..12d471d2a90b 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -5209,25 +5209,35 @@ static void mlxsw_sp_router_fibmr_event_work(struct work_struct *work)
static void mlxsw_sp_router_fib4_event(struct mlxsw_sp_fib_event_work *fib_work,
struct fib_notifier_info *info)
{
+ struct fib_entry_notifier_info *fen_info;
+ struct fib_rule_notifier_info *fr_info;
+ struct fib_nh_notifier_info *fnh_info;
+
switch (fib_work->event) {
case FIB_EVENT_ENTRY_REPLACE: /* fall through */
case FIB_EVENT_ENTRY_APPEND: /* fall through */
case FIB_EVENT_ENTRY_ADD: /* fall through */
case FIB_EVENT_ENTRY_DEL:
- memcpy(&fib_work->fen_info, info, sizeof(fib_work->fen_info));
- /* Take referece on fib_info to prevent it from being
+ fen_info = container_of(info, struct fib_entry_notifier_info,
+ info);
+ fib_work->fen_info = *fen_info;
+ /* Take reference on fib_info to prevent it from being
* freed while work is queued. Release it afterwards.
*/
fib_info_hold(fib_work->fen_info.fi);
break;
case FIB_EVENT_RULE_ADD: /* fall through */
case FIB_EVENT_RULE_DEL:
- memcpy(&fib_work->fr_info, info, sizeof(fib_work->fr_info));
+ fr_info = container_of(info, struct fib_rule_notifier_info,
+ info);
+ fib_work->fr_info = *fr_info;
fib_rule_get(fib_work->fr_info.rule);
break;
case FIB_EVENT_NH_ADD: /* fall through */
case FIB_EVENT_NH_DEL:
- memcpy(&fib_work->fnh_info, info, sizeof(fib_work->fnh_info));
+ fnh_info = container_of(info, struct fib_nh_notifier_info,
+ info);
+ fib_work->fnh_info = *fnh_info;
fib_info_hold(fib_work->fnh_info.fib_nh->nh_parent);
break;
}
@@ -5236,16 +5246,23 @@ static void mlxsw_sp_router_fib4_event(struct mlxsw_sp_fib_event_work *fib_work,
static void mlxsw_sp_router_fib6_event(struct mlxsw_sp_fib_event_work *fib_work,
struct fib_notifier_info *info)
{
+ struct fib6_entry_notifier_info *fen6_info;
+ struct fib_rule_notifier_info *fr_info;
+
switch (fib_work->event) {
case FIB_EVENT_ENTRY_REPLACE: /* fall through */
case FIB_EVENT_ENTRY_ADD: /* fall through */
case FIB_EVENT_ENTRY_DEL:
- memcpy(&fib_work->fen6_info, info, sizeof(fib_work->fen6_info));
+ fen6_info = container_of(info, struct fib6_entry_notifier_info,
+ info);
+ fib_work->fen6_info = *fen6_info;
rt6_hold(fib_work->fen6_info.rt);
break;
case FIB_EVENT_RULE_ADD: /* fall through */
case FIB_EVENT_RULE_DEL:
- memcpy(&fib_work->fr_info, info, sizeof(fib_work->fr_info));
+ fr_info = container_of(info, struct fib_rule_notifier_info,
+ info);
+ fib_work->fr_info = *fr_info;
fib_rule_get(fib_work->fr_info.rule);
break;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] spectrum: Convert fib event handlers to use container_of on info arg
2017-10-18 22:01 [PATCH net-next] spectrum: Convert fib event handlers to use container_of on info arg David Ahern
@ 2017-10-19 7:09 ` Jiri Pirko
2017-10-21 0:45 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2017-10-19 7:09 UTC (permalink / raw)
To: David Ahern; +Cc: netdev, jiri, idosch
Thu, Oct 19, 2017 at 12:01:38AM CEST, dsahern@gmail.com wrote:
>Use container_of to convert the generic fib_notifier_info into
>the event specific data structure.
>
>Signed-off-by: David Ahern <dsahern@gmail.com>
>Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] spectrum: Convert fib event handlers to use container_of on info arg
2017-10-18 22:01 [PATCH net-next] spectrum: Convert fib event handlers to use container_of on info arg David Ahern
2017-10-19 7:09 ` Jiri Pirko
@ 2017-10-21 0:45 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-10-21 0:45 UTC (permalink / raw)
To: dsahern; +Cc: netdev, jiri, idosch
From: David Ahern <dsahern@gmail.com>
Date: Wed, 18 Oct 2017 15:01:38 -0700
> Use container_of to convert the generic fib_notifier_info into
> the event specific data structure.
>
> Signed-off-by: David Ahern <dsahern@gmail.com>
> Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-21 0:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-18 22:01 [PATCH net-next] spectrum: Convert fib event handlers to use container_of on info arg David Ahern
2017-10-19 7:09 ` Jiri Pirko
2017-10-21 0:45 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.