Attention is currently required from: cron2, flichtenheld, plaisthos.

Hello cron2, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1675?usp=email

to look at the new patch set (#5).

The following approvals got outdated and were removed:
Code-Review-1 by cron2


Change subject: lladdr: Clean up code and BSD support
......................................................................

lladdr: Clean up code and BSD support

cppcheck complained about the creation of a useless
variable on Windows. With the old code this was not
fixable in a good way. So rewrite the whole code to
hopefully be much more readable.

While testing this we also found out that the old
code was not really working on Solaris, so disable
support for that.

Gert Doering contributed support for NetBSD.

Github: closes #1034
Change-Id: Ibe7b3c17176c97a1cbb4d9cc87735b05e62c4f43
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M src/openvpn/lladdr.c
1 file changed, 39 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/1675/5

diff --git a/src/openvpn/lladdr.c b/src/openvpn/lladdr.c
index d8bcad9..195245f 100644
--- a/src/openvpn/lladdr.c
+++ b/src/openvpn/lladdr.c
@@ -13,42 +13,55 @@
 #include "lladdr.h"
 #include "proto.h"

+#ifdef TARGET_LINUX
+static int
+set_lladdr_linux(openvpn_net_ctx_t *ctx, const char *ifname, const char 
*lladdr)
+{
+    uint8_t addr[OPENVPN_ETH_ALEN];
+
+    sscanf(lladdr, MAC_FMT, MAC_SCAN_ARG(addr));
+    return (net_addr_ll_set(ctx, ifname, addr) == 0);
+}
+#else /* TARGET_LINUX */
+
+#if defined(TARGET_OPENBSD) || defined(TARGET_FREEBSD) || 
defined(TARGET_DARWIN)
+#define IFCONFIG_LLADDR_FMT "%s %s lladdr %s"
+#elif defined(TARGET_NETBSD)
+#define IFCONFIG_LLADDR_FMT "%s %s link %s active"
+#endif
+static int
+set_lladdr_ifconfig(const char *ifname, const char *lladdr, const struct 
env_set *es)
+{
+#ifdef IFCONFIG_LLADDR_FMT
+    struct argv argv = argv_new();
+    argv_printf(&argv, IFCONFIG_LLADDR_FMT, IFCONFIG_PATH, ifname, lladdr);
+    argv_msg(M_INFO, &argv);
+    int r = openvpn_execve_check(&argv, es, M_WARN, "ERROR: Unable to set link 
layer address.");
+    argv_free(&argv);
+    return r;
+#else
+    msg(M_WARN,
+        "Sorry, but I don't know how to configure link layer addresses on this 
operating system.");
+    return -1;
+#endif
+}
+#endif /* TARGET_LINUX */
+
 int
 set_lladdr(openvpn_net_ctx_t *ctx, const char *ifname, const char *lladdr, 
const struct env_set *es)
 {
-    int r;
-
     if (!ifname || !lladdr)
     {
         return -1;
     }

 #if defined(TARGET_LINUX)
-    uint8_t addr[OPENVPN_ETH_ALEN];
+    int r = set_lladdr_linux(ctx, ifname, lladdr);
+#else
+    int r = set_lladdr_ifconfig(ifname, lladdr, es);
+#endif

-    sscanf(lladdr, MAC_FMT, MAC_SCAN_ARG(addr));
-    r = (net_addr_ll_set(ctx, ifname, addr) == 0);
-#else /* if defined(TARGET_LINUX) */
-    struct argv argv = argv_new();
-#if defined(TARGET_SOLARIS)
-    argv_printf(&argv, "%s %s ether %s", IFCONFIG_PATH, ifname, lladdr);
-#elif defined(TARGET_OPENBSD)
-    argv_printf(&argv, "%s %s lladdr %s", IFCONFIG_PATH, ifname, lladdr);
-#elif defined(TARGET_DARWIN)
-    argv_printf(&argv, "%s %s lladdr %s", IFCONFIG_PATH, ifname, lladdr);
-#elif defined(TARGET_FREEBSD)
-    argv_printf(&argv, "%s %s ether %s", IFCONFIG_PATH, ifname, lladdr);
-#else  /* if defined(TARGET_SOLARIS) */
-    msg(M_WARN,
-        "Sorry, but I don't know how to configure link layer addresses on this 
operating system.");
-    return -1;
-#endif /* if defined(TARGET_SOLARIS) */
-    argv_msg(M_INFO, &argv);
-    r = openvpn_execve_check(&argv, es, M_WARN, "ERROR: Unable to set link 
layer address.");
-    argv_free(&argv);
-#endif /* if defined(TARGET_LINUX) */
-
-    if (r)
+    if (r > 0)
     {
         msg(M_INFO, "TUN/TAP link layer address set to %s", lladdr);
     }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1675?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ibe7b3c17176c97a1cbb4d9cc87735b05e62c4f43
Gerrit-Change-Number: 1675
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: cron2 <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: cron2 <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to