]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
mlxsw: spectrum_router: Demultiplex FIB event based on family
authorIdo Schimmel <idosch@mellanox.com>
Thu, 3 Aug 2017 11:28:26 +0000 (13:28 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Aug 2017 22:36:00 +0000 (15:36 -0700)
The FIB notification block currently only handles IPv4 events, but we
want to start handling IPv6 events soon, so lay the groundwork now.

Do that by preparing the work item and process it according to the
notified address family.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 78c19512250dea04883479a61c1e683e1313d6da..166ecf5d58f1789a55505371fcf7dee233ac0db2 100644 (file)
@@ -3040,7 +3040,7 @@ struct mlxsw_sp_fib_event_work {
        unsigned long event;
 };
 
-static void mlxsw_sp_router_fib_event_work(struct work_struct *work)
+static void mlxsw_sp_router_fib4_event_work(struct work_struct *work)
 {
        struct mlxsw_sp_fib_event_work *fib_work =
                container_of(work, struct mlxsw_sp_fib_event_work, work);
@@ -3085,6 +3085,42 @@ static void mlxsw_sp_router_fib_event_work(struct work_struct *work)
        kfree(fib_work);
 }
 
+static void mlxsw_sp_router_fib6_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)
+{
+       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
+                * 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));
+               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));
+               fib_info_hold(fib_work->fnh_info.fib_nh->nh_parent);
+               break;
+       }
+}
+
+static void mlxsw_sp_router_fib6_event(struct mlxsw_sp_fib_event_work *fib_work,
+                                      struct fib_notifier_info *info)
+{
+}
+
 /* Called with rcu_read_lock() */
 static int mlxsw_sp_router_fib_event(struct notifier_block *nb,
                                     unsigned long event, void *ptr)
@@ -3100,31 +3136,18 @@ static int mlxsw_sp_router_fib_event(struct notifier_block *nb,
        if (WARN_ON(!fib_work))
                return NOTIFY_BAD;
 
-       INIT_WORK(&fib_work->work, mlxsw_sp_router_fib_event_work);
        router = container_of(nb, struct mlxsw_sp_router, fib_nb);
        fib_work->mlxsw_sp = router->mlxsw_sp;
        fib_work->event = event;
 
-       switch (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, ptr, sizeof(fib_work->fen_info));
-               /* Take referece on fib_info to prevent it from being
-                * freed while work is queued. Release it afterwards.
-                */
-               fib_info_hold(fib_work->fen_info.fi);
+       switch (info->family) {
+       case AF_INET:
+               INIT_WORK(&fib_work->work, mlxsw_sp_router_fib4_event_work);
+               mlxsw_sp_router_fib4_event(fib_work, info);
                break;
-       case FIB_EVENT_RULE_ADD: /* fall through */
-       case FIB_EVENT_RULE_DEL:
-               memcpy(&fib_work->fr_info, ptr, sizeof(fib_work->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, ptr, sizeof(fib_work->fnh_info));
-               fib_info_hold(fib_work->fnh_info.fib_nh->nh_parent);
+       case AF_INET6:
+               INIT_WORK(&fib_work->work, mlxsw_sp_router_fib6_event_work);
+               mlxsw_sp_router_fib6_event(fib_work, info);
                break;
        }