batman-adv: split routing API data structure in subobjects
authorAntonio Quartulli <a@unstable.cc>
Wed, 25 May 2016 15:27:31 +0000 (23:27 +0800)
committerSimon Wunderlich <sw@simonwunderlich.de>
Mon, 4 Jul 2016 10:37:19 +0000 (12:37 +0200)
The routing API data structure contains several function
pointers that can easily be grouped together based on the
component they work with.

Split the API in subobjects in order to improve definition readability.

At the same time, remove the "bat_" prefix from the API object and
its fields names. These are batman-adv private structs and there is no
need to always prepend such prefix, which only makes function invocations
much much longer.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Reviewed-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
12 files changed:
net/batman-adv/bat_algo.c
net/batman-adv/bat_iv_ogm.c
net/batman-adv/bat_v.c
net/batman-adv/bat_v_elp.c
net/batman-adv/bat_v_ogm.c
net/batman-adv/hard-interface.c
net/batman-adv/netlink.c
net/batman-adv/originator.c
net/batman-adv/routing.c
net/batman-adv/sysfs.c
net/batman-adv/translation-table.c
net/batman-adv/types.h

index 610d4de0f6b000969395df3e5311db69f4938d86..81dbbf569bd4a0104387442b72e9ffd0463cde0f 100644 (file)
@@ -65,12 +65,12 @@ int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
        }
 
        /* all algorithms must implement all ops (for now) */
-       if (!bat_algo_ops->bat_iface_enable ||
-           !bat_algo_ops->bat_iface_disable ||
-           !bat_algo_ops->bat_iface_update_mac ||
-           !bat_algo_ops->bat_primary_iface_set ||
-           !bat_algo_ops->bat_neigh_cmp ||
-           !bat_algo_ops->bat_neigh_is_similar_or_better) {
+       if (!bat_algo_ops->iface.enable ||
+           !bat_algo_ops->iface.disable ||
+           !bat_algo_ops->iface.update_mac ||
+           !bat_algo_ops->iface.primary_set ||
+           !bat_algo_ops->neigh.cmp ||
+           !bat_algo_ops->neigh.is_similar_or_better) {
                pr_info("Routing algo '%s' does not implement required ops\n",
                        bat_algo_ops->name);
                return -EINVAL;
@@ -90,7 +90,7 @@ int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
        if (!bat_algo_ops)
                return -EINVAL;
 
-       bat_priv->bat_algo_ops = bat_algo_ops;
+       bat_priv->algo_ops = bat_algo_ops;
 
        return 0;
 }
index e2d8848c32c034817c928e75a66051528a543b28..19b0abd6c640e26f11b26b7fd6f3eea82134e2ee 100644 (file)
@@ -1853,8 +1853,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
        /* did we receive a B.A.T.M.A.N. IV OGM packet on an interface
         * that does not have B.A.T.M.A.N. IV enabled ?
         */
-       if (bat_priv->bat_algo_ops->bat_iface_enable !=
-           batadv_iv_ogm_iface_enable)
+       if (bat_priv->algo_ops->iface.enable != batadv_iv_ogm_iface_enable)
                return NET_RX_DROP;
 
        batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX);
@@ -2120,18 +2119,24 @@ static void batadv_iv_iface_activate(struct batadv_hard_iface *hard_iface)
 
 static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
        .name = "BATMAN_IV",
-       .bat_iface_activate = batadv_iv_iface_activate,
-       .bat_iface_enable = batadv_iv_ogm_iface_enable,
-       .bat_iface_disable = batadv_iv_ogm_iface_disable,
-       .bat_iface_update_mac = batadv_iv_ogm_iface_update_mac,
-       .bat_primary_iface_set = batadv_iv_ogm_primary_iface_set,
-       .bat_neigh_cmp = batadv_iv_ogm_neigh_cmp,
-       .bat_neigh_is_similar_or_better = batadv_iv_ogm_neigh_is_sob,
-       .bat_neigh_print = batadv_iv_neigh_print,
-       .bat_orig_print = batadv_iv_ogm_orig_print,
-       .bat_orig_free = batadv_iv_ogm_orig_free,
-       .bat_orig_add_if = batadv_iv_ogm_orig_add_if,
-       .bat_orig_del_if = batadv_iv_ogm_orig_del_if,
+       .iface = {
+               .activate = batadv_iv_iface_activate,
+               .enable = batadv_iv_ogm_iface_enable,
+               .disable = batadv_iv_ogm_iface_disable,
+               .update_mac = batadv_iv_ogm_iface_update_mac,
+               .primary_set = batadv_iv_ogm_primary_iface_set,
+       },
+       .neigh = {
+               .cmp = batadv_iv_ogm_neigh_cmp,
+               .is_similar_or_better = batadv_iv_ogm_neigh_is_sob,
+               .print = batadv_iv_neigh_print,
+       },
+       .orig = {
+               .print = batadv_iv_ogm_orig_print,
+               .free = batadv_iv_ogm_orig_free,
+               .add_if = batadv_iv_ogm_orig_add_if,
+               .del_if = batadv_iv_ogm_orig_del_if,
+       },
 };
 
 int __init batadv_iv_init(void)
index 7231440bed51ce1af6ef189728fd114ab3457d5c..0366cbf5e44456925fc81bd6b15042482c7718a5 100644 (file)
@@ -322,16 +322,22 @@ err_ifinfo1:
 
 static struct batadv_algo_ops batadv_batman_v __read_mostly = {
        .name = "BATMAN_V",
-       .bat_iface_activate = batadv_v_iface_activate,
-       .bat_iface_enable = batadv_v_iface_enable,
-       .bat_iface_disable = batadv_v_iface_disable,
-       .bat_iface_update_mac = batadv_v_iface_update_mac,
-       .bat_primary_iface_set = batadv_v_primary_iface_set,
-       .bat_hardif_neigh_init = batadv_v_hardif_neigh_init,
-       .bat_orig_print = batadv_v_orig_print,
-       .bat_neigh_cmp = batadv_v_neigh_cmp,
-       .bat_neigh_is_similar_or_better = batadv_v_neigh_is_sob,
-       .bat_neigh_print = batadv_v_neigh_print,
+       .iface = {
+               .activate = batadv_v_iface_activate,
+               .enable = batadv_v_iface_enable,
+               .disable = batadv_v_iface_disable,
+               .update_mac = batadv_v_iface_update_mac,
+               .primary_set = batadv_v_primary_iface_set,
+       },
+       .neigh = {
+               .hardif_init = batadv_v_hardif_neigh_init,
+               .cmp = batadv_v_neigh_cmp,
+               .is_similar_or_better = batadv_v_neigh_is_sob,
+               .print = batadv_v_neigh_print,
+       },
+       .orig = {
+               .print = batadv_v_orig_print,
+       },
 };
 
 /**
index 15cf2726d6a55032c6decd814164f4c7b3c5d826..7d170010beb9050ffbb90aff463c16cde60e144d 100644 (file)
@@ -504,7 +504,7 @@ int batadv_v_elp_packet_recv(struct sk_buff *skb,
        /* did we receive a B.A.T.M.A.N. V ELP packet on an interface
         * that does not have B.A.T.M.A.N. V ELP enabled ?
         */
-       if (strcmp(bat_priv->bat_algo_ops->name, "BATMAN_V") != 0)
+       if (strcmp(bat_priv->algo_ops->name, "BATMAN_V") != 0)
                return NET_RX_DROP;
 
        elp_packet = (struct batadv_elp_packet *)skb->data;
index 7ac9e0b306180bbf77af4a65030ede3cd939ff81..6fbba4eb06171161d41d15efc7e0e525d1c0fe85 100644 (file)
@@ -754,7 +754,7 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb,
        /* did we receive a OGM2 packet on an interface that does not have
         * B.A.T.M.A.N. V enabled ?
         */
-       if (strcmp(bat_priv->bat_algo_ops->name, "BATMAN_V") != 0)
+       if (strcmp(bat_priv->algo_ops->name, "BATMAN_V") != 0)
                return NET_RX_DROP;
 
        if (!batadv_check_management_packet(skb, if_incoming, BATADV_OGM2_HLEN))
index 70841c1e00696fd6407f8be270d1dbde1e6a47ac..1f9080840566720fdce2ddaff2a8e9c24084231e 100644 (file)
@@ -247,7 +247,7 @@ static void batadv_primary_if_select(struct batadv_priv *bat_priv,
        if (!new_hard_iface)
                goto out;
 
-       bat_priv->bat_algo_ops->bat_primary_iface_set(new_hard_iface);
+       bat_priv->algo_ops->iface.primary_set(new_hard_iface);
        batadv_primary_if_update_addr(bat_priv, curr_hard_iface);
 
 out:
@@ -394,7 +394,7 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
 
        bat_priv = netdev_priv(hard_iface->soft_iface);
 
-       bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface);
+       bat_priv->algo_ops->iface.update_mac(hard_iface);
        hard_iface->if_status = BATADV_IF_TO_BE_ACTIVATED;
 
        /* the first active interface becomes our primary interface or
@@ -409,8 +409,8 @@ batadv_hardif_activate_interface(struct batadv_hard_iface *hard_iface)
 
        batadv_update_min_mtu(hard_iface->soft_iface);
 
-       if (bat_priv->bat_algo_ops->bat_iface_activate)
-               bat_priv->bat_algo_ops->bat_iface_activate(hard_iface);
+       if (bat_priv->algo_ops->iface.activate)
+               bat_priv->algo_ops->iface.activate(hard_iface);
 
 out:
        if (primary_if)
@@ -508,7 +508,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
        if (ret)
                goto err_dev;
 
-       ret = bat_priv->bat_algo_ops->bat_iface_enable(hard_iface);
+       ret = bat_priv->algo_ops->iface.enable(hard_iface);
        if (ret < 0)
                goto err_upper;
 
@@ -517,7 +517,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
        hard_iface->if_status = BATADV_IF_INACTIVE;
        ret = batadv_orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
        if (ret < 0) {
-               bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
+               bat_priv->algo_ops->iface.disable(hard_iface);
                bat_priv->num_ifaces--;
                hard_iface->if_status = BATADV_IF_NOT_IN_USE;
                goto err_upper;
@@ -598,7 +598,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
                        batadv_hardif_put(new_if);
        }
 
-       bat_priv->bat_algo_ops->bat_iface_disable(hard_iface);
+       bat_priv->algo_ops->iface.disable(hard_iface);
        hard_iface->if_status = BATADV_IF_NOT_IN_USE;
 
        /* delete all references to this hard_iface */
@@ -783,7 +783,7 @@ static int batadv_hard_if_event(struct notifier_block *this,
                batadv_check_known_mac_addr(hard_iface->net_dev);
 
                bat_priv = netdev_priv(hard_iface->soft_iface);
-               bat_priv->bat_algo_ops->bat_iface_update_mac(hard_iface);
+               bat_priv->algo_ops->iface.update_mac(hard_iface);
 
                primary_if = batadv_primary_if_get_selected(bat_priv);
                if (!primary_if)
index c25bbb8ab06c99881f702185ba379c74de4507aa..231f8eaf075b2e9c9296bb71a3a4588d258ccc17 100644 (file)
@@ -89,7 +89,7 @@ batadv_netlink_mesh_info_put(struct sk_buff *msg, struct net_device *soft_iface)
 
        if (nla_put_string(msg, BATADV_ATTR_VERSION, BATADV_SOURCE_VERSION) ||
            nla_put_string(msg, BATADV_ATTR_ALGO_NAME,
-                          bat_priv->bat_algo_ops->name) ||
+                          bat_priv->algo_ops->name) ||
            nla_put_u32(msg, BATADV_ATTR_MESH_IFINDEX, soft_iface->ifindex) ||
            nla_put_string(msg, BATADV_ATTR_MESH_IFNAME, soft_iface->name) ||
            nla_put(msg, BATADV_ATTR_MESH_ADDRESS, ETH_ALEN,
index 8ad17ad477e41d765c4dc2bb555309d2bcb9ecf7..7d1e5421f6bc6ce81b6380cdf19d28cafe6fd661 100644 (file)
@@ -534,8 +534,8 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
 
        kref_init(&hardif_neigh->refcount);
 
-       if (bat_priv->bat_algo_ops->bat_hardif_neigh_init)
-               bat_priv->bat_algo_ops->bat_hardif_neigh_init(hardif_neigh);
+       if (bat_priv->algo_ops->neigh.hardif_init)
+               bat_priv->algo_ops->neigh.hardif_init(hardif_neigh);
 
        hlist_add_head(&hardif_neigh->list, &hard_iface->neigh_list);
 
@@ -706,17 +706,17 @@ int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset)
        seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n",
                   BATADV_SOURCE_VERSION, primary_if->net_dev->name,
                   primary_if->net_dev->dev_addr, net_dev->name,
-                  bat_priv->bat_algo_ops->name);
+                  bat_priv->algo_ops->name);
 
        batadv_hardif_put(primary_if);
 
-       if (!bat_priv->bat_algo_ops->bat_neigh_print) {
+       if (!bat_priv->algo_ops->neigh.print) {
                seq_puts(seq,
                         "No printing function for this routing protocol\n");
                return 0;
        }
 
-       bat_priv->bat_algo_ops->bat_neigh_print(bat_priv, seq);
+       bat_priv->algo_ops->neigh.print(bat_priv, seq);
        return 0;
 }
 
@@ -767,8 +767,8 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
 
        batadv_frag_purge_orig(orig_node, NULL);
 
-       if (orig_node->bat_priv->bat_algo_ops->bat_orig_free)
-               orig_node->bat_priv->bat_algo_ops->bat_orig_free(orig_node);
+       if (orig_node->bat_priv->algo_ops->orig.free)
+               orig_node->bat_priv->algo_ops->orig.free(orig_node);
 
        kfree(orig_node->tt_buff);
        kfree(orig_node);
@@ -1097,12 +1097,12 @@ batadv_find_best_neighbor(struct batadv_priv *bat_priv,
                          struct batadv_hard_iface *if_outgoing)
 {
        struct batadv_neigh_node *best = NULL, *neigh;
-       struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
+       struct batadv_algo_ops *bao = bat_priv->algo_ops;
 
        rcu_read_lock();
        hlist_for_each_entry_rcu(neigh, &orig_node->neigh_list, list) {
-               if (best && (bao->bat_neigh_cmp(neigh, if_outgoing,
-                                               best, if_outgoing) <= 0))
+               if (best && (bao->neigh.cmp(neigh, if_outgoing, best,
+                                           if_outgoing) <= 0))
                        continue;
 
                if (!kref_get_unless_zero(&neigh->refcount))
@@ -1254,18 +1254,17 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
        seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n",
                   BATADV_SOURCE_VERSION, primary_if->net_dev->name,
                   primary_if->net_dev->dev_addr, net_dev->name,
-                  bat_priv->bat_algo_ops->name);
+                  bat_priv->algo_ops->name);
 
        batadv_hardif_put(primary_if);
 
-       if (!bat_priv->bat_algo_ops->bat_orig_print) {
+       if (!bat_priv->algo_ops->orig.print) {
                seq_puts(seq,
                         "No printing function for this routing protocol\n");
                return 0;
        }
 
-       bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq,
-                                              BATADV_IF_DEFAULT);
+       bat_priv->algo_ops->orig.print(bat_priv, seq, BATADV_IF_DEFAULT);
 
        return 0;
 }
@@ -1292,7 +1291,7 @@ int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset)
        }
 
        bat_priv = netdev_priv(hard_iface->soft_iface);
-       if (!bat_priv->bat_algo_ops->bat_orig_print) {
+       if (!bat_priv->algo_ops->orig.print) {
                seq_puts(seq,
                         "No printing function for this routing protocol\n");
                goto out;
@@ -1306,9 +1305,9 @@ int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset)
        seq_printf(seq, "[B.A.T.M.A.N. adv %s, IF/MAC: %s/%pM (%s %s)]\n",
                   BATADV_SOURCE_VERSION, hard_iface->net_dev->name,
                   hard_iface->net_dev->dev_addr,
-                  hard_iface->soft_iface->name, bat_priv->bat_algo_ops->name);
+                  hard_iface->soft_iface->name, bat_priv->algo_ops->name);
 
-       bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq, hard_iface);
+       bat_priv->algo_ops->orig.print(bat_priv, seq, hard_iface);
 
 out:
        if (hard_iface)
@@ -1320,7 +1319,7 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
                            int max_if_num)
 {
        struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
-       struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
+       struct batadv_algo_ops *bao = bat_priv->algo_ops;
        struct batadv_hashtable *hash = bat_priv->orig_hash;
        struct hlist_head *head;
        struct batadv_orig_node *orig_node;
@@ -1336,9 +1335,8 @@ int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
                rcu_read_lock();
                hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
                        ret = 0;
-                       if (bao->bat_orig_add_if)
-                               ret = bao->bat_orig_add_if(orig_node,
-                                                          max_if_num);
+                       if (bao->orig.add_if)
+                               ret = bao->orig.add_if(orig_node, max_if_num);
                        if (ret == -ENOMEM)
                                goto err;
                }
@@ -1360,7 +1358,7 @@ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
        struct hlist_head *head;
        struct batadv_hard_iface *hard_iface_tmp;
        struct batadv_orig_node *orig_node;
-       struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
+       struct batadv_algo_ops *bao = bat_priv->algo_ops;
        u32 i;
        int ret;
 
@@ -1373,10 +1371,9 @@ int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
                rcu_read_lock();
                hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
                        ret = 0;
-                       if (bao->bat_orig_del_if)
-                               ret = bao->bat_orig_del_if(orig_node,
-                                                          max_if_num,
-                                                          hard_iface->if_num);
+                       if (bao->orig.del_if)
+                               ret = bao->orig.del_if(orig_node, max_if_num,
+                                                      hard_iface->if_num);
                        if (ret == -ENOMEM)
                                goto err;
                }
index 7b5de402ee0dff13e181f26e840f019fbb3bf4fd..0f8c0ddf7816c79e0dc6077dcedfe411269345c2 100644 (file)
@@ -482,7 +482,7 @@ batadv_find_router(struct batadv_priv *bat_priv,
                   struct batadv_orig_node *orig_node,
                   struct batadv_hard_iface *recv_if)
 {
-       struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
+       struct batadv_algo_ops *bao = bat_priv->algo_ops;
        struct batadv_neigh_node *first_candidate_router = NULL;
        struct batadv_neigh_node *next_candidate_router = NULL;
        struct batadv_neigh_node *router, *cand_router = NULL;
@@ -536,9 +536,9 @@ batadv_find_router(struct batadv_priv *bat_priv,
                /* alternative candidate should be good enough to be
                 * considered
                 */
-               if (!bao->bat_neigh_is_similar_or_better(cand_router,
-                                                        cand->if_outgoing,
-                                                        router, recv_if))
+               if (!bao->neigh.is_similar_or_better(cand_router,
+                                                    cand->if_outgoing, router,
+                                                    recv_if))
                        goto next;
 
                /* don't use the same router twice */
index 1a7942ddf7300d49287f55db08bb946c7fb039b4..fe9ca94ddee2a2da3ce18baace7487c3db54ba53 100644 (file)
@@ -412,7 +412,7 @@ static ssize_t batadv_show_bat_algo(struct kobject *kobj,
 {
        struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
 
-       return sprintf(buff, "%s\n", bat_priv->bat_algo_ops->name);
+       return sprintf(buff, "%s\n", bat_priv->algo_ops->name);
 }
 
 static void batadv_post_gw_reselect(struct net_device *net_dev)
index 48ce7889a3e83e92efe9519b2e7547daffb6631f..8bb82a391490c57b1832d9104eb6a7877a45f1ac 100644 (file)
@@ -1546,7 +1546,7 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv,
                            struct batadv_tt_global_entry *tt_global_entry)
 {
        struct batadv_neigh_node *router, *best_router = NULL;
-       struct batadv_algo_ops *bao = bat_priv->bat_algo_ops;
+       struct batadv_algo_ops *bao = bat_priv->algo_ops;
        struct hlist_head *head;
        struct batadv_tt_orig_list_entry *orig_entry, *best_entry = NULL;
 
@@ -1558,8 +1558,8 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv,
                        continue;
 
                if (best_router &&
-                   bao->bat_neigh_cmp(router, BATADV_IF_DEFAULT,
-                                      best_router, BATADV_IF_DEFAULT) <= 0) {
+                   bao->neigh.cmp(router, BATADV_IF_DEFAULT, best_router,
+                                  BATADV_IF_DEFAULT) <= 0) {
                        batadv_neigh_node_put(router);
                        continue;
                }
index a331e3ab93d1badf3d20a284a421f7d19046e319..4d6a7ce3f83c50387e2665897b783a946b48381a 100644 (file)
@@ -1016,7 +1016,7 @@ struct batadv_priv_bat_v {
  * @cleanup_work: work queue callback item for soft-interface deinit
  * @primary_if: one of the hard-interfaces assigned to this mesh interface
  *  becomes the primary interface
- * @bat_algo_ops: routing algorithm used by this mesh interface
+ * @algo_ops: routing algorithm used by this mesh interface
  * @softif_vlan_list: a list of softif_vlan structs, one per VLAN created on top
  *  of the mesh interface represented by this object
  * @softif_vlan_list_lock: lock protecting softif_vlan_list
@@ -1074,7 +1074,7 @@ struct batadv_priv {
        struct delayed_work orig_work;
        struct work_struct cleanup_work;
        struct batadv_hard_iface __rcu *primary_if;  /* rcu protected pointer */
-       struct batadv_algo_ops *bat_algo_ops;
+       struct batadv_algo_ops *algo_ops;
        struct hlist_head softif_vlan_list;
        spinlock_t softif_vlan_list_lock; /* protects softif_vlan_list */
 #ifdef CONFIG_BATMAN_ADV_BLA
@@ -1387,60 +1387,78 @@ struct batadv_forw_packet {
        struct batadv_hard_iface *if_outgoing;
 };
 
+/**
+ * struct batadv_algo_iface_ops - mesh algorithm callbacks (interface specific)
+ * @activate: start routing mechanisms when hard-interface is brought up
+ * @enable: init routing info when hard-interface is enabled
+ * @disable: de-init routing info when hard-interface is disabled
+ * @update_mac: (re-)init mac addresses of the protocol information
+ *  belonging to this hard-interface
+ * @primary_set: called when primary interface is selected / changed
+ */
+struct batadv_algo_iface_ops {
+       void (*activate)(struct batadv_hard_iface *hard_iface);
+       int (*enable)(struct batadv_hard_iface *hard_iface);
+       void (*disable)(struct batadv_hard_iface *hard_iface);
+       void (*update_mac)(struct batadv_hard_iface *hard_iface);
+       void (*primary_set)(struct batadv_hard_iface *hard_iface);
+};
+
+/**
+ * struct batadv_algo_neigh_ops - mesh algorithm callbacks (neighbour specific)
+ * @hardif_init: called on creation of single hop entry
+ * @cmp: compare the metrics of two neighbors for their respective outgoing
+ *  interfaces
+ * @is_similar_or_better: check if neigh1 is equally similar or better than
+ *  neigh2 for their respective outgoing interface from the metric prospective
+ * @print: print the single hop neighbor list (optional)
+ */
+struct batadv_algo_neigh_ops {
+       void (*hardif_init)(struct batadv_hardif_neigh_node *neigh);
+       int (*cmp)(struct batadv_neigh_node *neigh1,
+                  struct batadv_hard_iface *if_outgoing1,
+                  struct batadv_neigh_node *neigh2,
+                  struct batadv_hard_iface *if_outgoing2);
+       bool (*is_similar_or_better)(struct batadv_neigh_node *neigh1,
+                                    struct batadv_hard_iface *if_outgoing1,
+                                    struct batadv_neigh_node *neigh2,
+                                    struct batadv_hard_iface *if_outgoing2);
+       void (*print)(struct batadv_priv *priv, struct seq_file *seq);
+};
+
+/**
+ * struct batadv_algo_orig_ops - mesh algorithm callbacks (originator specific)
+ * @free: free the resources allocated by the routing algorithm for an orig_node
+ *  object
+ * @add_if: ask the routing algorithm to apply the needed changes to the
+ *  orig_node due to a new hard-interface being added into the mesh
+ * @del_if: ask the routing algorithm to apply the needed changes to the
+ *  orig_node due to an hard-interface being removed from the mesh
+ * @print: print the originator table (optional)
+ */
+struct batadv_algo_orig_ops {
+       void (*free)(struct batadv_orig_node *orig_node);
+       int (*add_if)(struct batadv_orig_node *orig_node, int max_if_num);
+       int (*del_if)(struct batadv_orig_node *orig_node, int max_if_num,
+                     int del_if_num);
+       void (*print)(struct batadv_priv *priv, struct seq_file *seq,
+                     struct batadv_hard_iface *hard_iface);
+};
+
 /**
  * struct batadv_algo_ops - mesh algorithm callbacks
  * @list: list node for the batadv_algo_list
  * @name: name of the algorithm
- * @bat_iface_activate: start routing mechanisms when hard-interface is brought
- *  up
- * @bat_iface_enable: init routing info when hard-interface is enabled
- * @bat_iface_disable: de-init routing info when hard-interface is disabled
- * @bat_iface_update_mac: (re-)init mac addresses of the protocol information
- *  belonging to this hard-interface
- * @bat_primary_iface_set: called when primary interface is selected / changed
- * @bat_hardif_neigh_init: called on creation of single hop entry
- * @bat_neigh_cmp: compare the metrics of two neighbors for their respective
- *  outgoing interfaces
- * @bat_neigh_is_similar_or_better: check if neigh1 is equally similar or
- *  better than neigh2 for their respective outgoing interface from the metric
- *  prospective
- * @bat_neigh_print: print the single hop neighbor list (optional)
- * @bat_orig_print: print the originator table (optional)
- * @bat_orig_free: free the resources allocated by the routing algorithm for an
- *  orig_node object
- * @bat_orig_add_if: ask the routing algorithm to apply the needed changes to
- *  the orig_node due to a new hard-interface being added into the mesh
- * @bat_orig_del_if: ask the routing algorithm to apply the needed changes to
- *  the orig_node due to an hard-interface being removed from the mesh
+ * @iface: callbacks related to interface handling
+ * @neigh: callbacks related to neighbors handling
+ * @orig: callbacks related to originators handling
  */
 struct batadv_algo_ops {
        struct hlist_node list;
        char *name;
-       void (*bat_iface_activate)(struct batadv_hard_iface *hard_iface);
-       int (*bat_iface_enable)(struct batadv_hard_iface *hard_iface);
-       void (*bat_iface_disable)(struct batadv_hard_iface *hard_iface);
-       void (*bat_iface_update_mac)(struct batadv_hard_iface *hard_iface);
-       void (*bat_primary_iface_set)(struct batadv_hard_iface *hard_iface);
-       /* neigh_node handling API */
-       void (*bat_hardif_neigh_init)(struct batadv_hardif_neigh_node *neigh);
-       int (*bat_neigh_cmp)(struct batadv_neigh_node *neigh1,
-                            struct batadv_hard_iface *if_outgoing1,
-                            struct batadv_neigh_node *neigh2,
-                            struct batadv_hard_iface *if_outgoing2);
-       bool (*bat_neigh_is_similar_or_better)
-               (struct batadv_neigh_node *neigh1,
-                struct batadv_hard_iface *if_outgoing1,
-                struct batadv_neigh_node *neigh2,
-                struct batadv_hard_iface *if_outgoing2);
-       void (*bat_neigh_print)(struct batadv_priv *priv, struct seq_file *seq);
-       /* orig_node handling API */
-       void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq,
-                              struct batadv_hard_iface *hard_iface);
-       void (*bat_orig_free)(struct batadv_orig_node *orig_node);
-       int (*bat_orig_add_if)(struct batadv_orig_node *orig_node,
-                              int max_if_num);
-       int (*bat_orig_del_if)(struct batadv_orig_node *orig_node,
-                              int max_if_num, int del_if_num);
+       struct batadv_algo_iface_ops iface;
+       struct batadv_algo_neigh_ops neigh;
+       struct batadv_algo_orig_ops orig;
 };
 
 /**