PATCH aöfred don't start idz within a network spaxce

Message ID 735c49a8-6ccd-9932-5835-27b59b3f1c98@t-online.de (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Jean-Jacques Sarton Nov. 1, 2016, 3:20 p.m. UTC
  Hello I hope that this will be a valid patch.

This patch shall allow to use the debugfs as previouly, including
the check for valify of the interface used.
For netns the check seem to be implemented within the function
netlink_query_common().
For netlink we check if the originators ans transtable_global
informations are accessible through netlink.


Signed-off-by: jj.sarton@t-online.de
---
  

Comments

Simon Wunderlich Nov. 1, 2016, 3:30 p.m. UTC | #1
On Tuesday, November 1, 2016 4:20:07 PM CET Jean-Jacques Sarton wrote:
> Hello I hope that this will be a valid patch.

This doesn't belong into the commit part of a patch.

And no, it doesn't apply:

$ git am -s /tmp/\[B.A.T.M.A.N.\]\ PATCH\ aöfred\ don\'t\ start\ idz\ within\ 
a\ network\ spaxce.mbox
Applying: PATCH aöfred don't start idz within a network spaxce
fatal: corrupt patch at line 7
Patch failed at 0001 PATCH aöfred don't start idz within a network spaxce
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Did you consider spellchecking your subject? There at least 3 typos in this 
single line, and PATCH should be in brackets [].

Svens technical remarks also haven't been considered.

On the plus side, you now have a subject (or something like that), a commit 
log, and a signed off, so I believe we are converging to a mergeable patch ...

But please, take some time and prepare the patch properly. At least we are not 
in a hurry.

Thank you,
     Simon

> 
> This patch shall allow to use the debugfs as previouly, including
> the check for valify of the interface used.
> For netns the check seem to be implemented within the function
> netlink_query_common().
> For netlink we check if the originators ans transtable_global
> informations are accessible through netlink.
> 
> 
> Signed-off-by: jj.sarton@t-online.de
> ---
> diff --git a/batadv_query.c b/batadv_query.c
> index a671b79..dc8a042 100644
> --- a/batadv_query.c
> +++ b/batadv_query.c
> @@ -136,7 +136,7 @@ int ipv6_to_mac(const struct in6_addr *addr, struct
> ether_addr *mac) return 0;
>  }
> 
> -int batadv_interface_check(const char *mesh_iface)
> +int batadv_interface_check_debugfs(const char *mesh_iface)
>  {
>         char full_path[MAX_PATH + 1];
>         FILE *f;
> @@ -166,6 +166,18 @@ int batadv_interface_check(const char *mesh_iface)
>         return 0;
>  }
> 
> +int batadv_interface_check(const char *mesh_iface)
> +{
> +       int ret = 0;
> +       enable_net_admin_capability(1);
> +       ret = batadv_interface_check_netlink(mesh_iface);
> +       enable_net_admin_capability(0);
> +
> +       if ( ret < 0 )
> +               return batadv_interface_check_debugfs(mesh_iface);
> +       return 0;
> +}
> +
>  static int translate_mac_debugfs(const char *mesh_iface,
>                                  const struct ether_addr *mac,
>                                  struct ether_addr *mac_out)
> diff --git a/netlink.c b/netlink.c
> index 1b5695c..9288770 100644
> --- a/netlink.c
> +++ b/netlink.c
> @@ -365,3 +365,30 @@ int get_tq_netlink(const char *mesh_iface, const struct
> ether_addr *mac,
> 
>         return 0;
>  }
> +
> +int batadv_interface_check_netlink(const char *mesh_iface)
> +{
> +       struct get_tq_netlink_opts opts = {
> +               .tq = 0,
> +               .found = false,
> +               .query_opts = {
> +                       .err = 0,
> +               },
> +       };
> +       int ret = 0;
> +
> +       memset(&opts.mac, 0, ETH_ALEN);
> +
> +       ret = netlink_query_common(mesh_iface,  BATADV_CMD_GET_ORIGINATORS,
> +                                  get_tq_netlink_cb, &opts.query_opts);
> +       if (ret < 0)
> +               return ret;
> +
> +       memset(&opts.mac, 0, ETH_ALEN);
> +       ret = netlink_query_common(mesh_iface,
> BATADV_CMD_GET_TRANSTABLE_GLOBAL, +                                 
> get_tq_netlink_cb, &opts.query_opts); +
> +       if (ret < 0)
> +               return ret;
> +       return 0;
> +}
> diff --git a/netlink.h b/netlink.h
> index b08e872..9bc75a1 100644
> --- a/netlink.h
> +++ b/netlink.h
> @@ -49,6 +49,7 @@ int translate_mac_netlink(const char *mesh_iface, const
> struct ether_addr *mac, struct ether_addr *mac_out);
>  int get_tq_netlink(const char *mesh_iface, const struct ether_addr *mac,
>                    uint8_t *tq);
> +int batadv_interface_check_netlink(const char *mesh_iface);
> 
>  extern struct nla_policy batadv_netlink_policy[];
  

Patch

diff --git a/batadv_query.c b/batadv_query.c
index a671b79..dc8a042 100644
--- a/batadv_query.c
+++ b/batadv_query.c
@@ -136,7 +136,7 @@  int ipv6_to_mac(const struct in6_addr *addr, struct ether_addr *mac)
        return 0;
 }

-int batadv_interface_check(const char *mesh_iface)
+int batadv_interface_check_debugfs(const char *mesh_iface)
 {
        char full_path[MAX_PATH + 1];
        FILE *f;
@@ -166,6 +166,18 @@  int batadv_interface_check(const char *mesh_iface)
        return 0;
 }

+int batadv_interface_check(const char *mesh_iface)
+{
+       int ret = 0;
+       enable_net_admin_capability(1);
+       ret = batadv_interface_check_netlink(mesh_iface);
+       enable_net_admin_capability(0);
+
+       if ( ret < 0 )
+               return batadv_interface_check_debugfs(mesh_iface);
+       return 0;
+}
+
 static int translate_mac_debugfs(const char *mesh_iface,
                                 const struct ether_addr *mac,
                                 struct ether_addr *mac_out)
diff --git a/netlink.c b/netlink.c
index 1b5695c..9288770 100644
--- a/netlink.c
+++ b/netlink.c
@@ -365,3 +365,30 @@  int get_tq_netlink(const char *mesh_iface, const struct ether_addr *mac,

        return 0;
 }
+
+int batadv_interface_check_netlink(const char *mesh_iface)
+{
+       struct get_tq_netlink_opts opts = {
+               .tq = 0,
+               .found = false,
+               .query_opts = {
+                       .err = 0,
+               },
+       };
+       int ret = 0;
+
+       memset(&opts.mac, 0, ETH_ALEN);
+
+       ret = netlink_query_common(mesh_iface,  BATADV_CMD_GET_ORIGINATORS,
+                                  get_tq_netlink_cb, &opts.query_opts);
+       if (ret < 0)
+               return ret;
+
+       memset(&opts.mac, 0, ETH_ALEN);
+       ret = netlink_query_common(mesh_iface, BATADV_CMD_GET_TRANSTABLE_GLOBAL,
+                                  get_tq_netlink_cb, &opts.query_opts);
+
+       if (ret < 0)
+               return ret;
+       return 0;
+}
diff --git a/netlink.h b/netlink.h
index b08e872..9bc75a1 100644
--- a/netlink.h
+++ b/netlink.h
@@ -49,6 +49,7 @@  int translate_mac_netlink(const char *mesh_iface, const struct ether_addr *mac,
                          struct ether_addr *mac_out);
 int get_tq_netlink(const char *mesh_iface, const struct ether_addr *mac,
                   uint8_t *tq);
+int batadv_interface_check_netlink(const char *mesh_iface);

 extern struct nla_policy batadv_netlink_policy[];