Skip to contentSkip to conversation

: cleanups prior to FreeBSD DCO support

PATCH New Kristof Provost 1 participant 4 messages Feb 22, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : cleanups prior to FreeBSD DCO support

Hi,

As said in my e-mail (from [email protected]..., Feb 17th), I'm working on adding DCO support for FreeBSD.
I ran into a few minor issues that are not directly related, but should be addressed anyway.

These patches are all against https://github.com/OpenVPN/ovpn-dco

Best regards,
Kristof

#1 lore raw

PATCH 1/3 dco: dco_meesage_peer_id -> dco_message_peer_id

From: Kristof Provost <[email protected]...>

Fix typo in variable name.

---
 src/openvpn/dco_linux.c | 6 +++---
 src/openvpn/dco_linux.h | 2 +-
 src/openvpn/multi.c     | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)
src/openvpn/dco_linux.c +3 -3
index 9fddb788..341e9ae7 100644
@@ -436,7 +436,7 @@ open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
     tt->actual_name = string_alloc(dev, NULL);
     uint8_t *dcobuf = malloc(65536);
     buf_set_write(&tt->dco.dco_packet_in, dcobuf, 65536);
-    tt->dco.dco_meesage_peer_id = -1;
+    tt->dco.dco_message_peer_id = -1;
 
     ovpn_dco_register(&tt->dco);
 
@@ -742,7 +742,7 @@ static int ovpn_handle_msg(struct nl_msg *msg, void *arg)
 
         msg(D_DCO_DEBUG, "ovpn-dco: received CMD_DEL_PEER, ifindex: %d, peer-id %d, reason: %d",
             ifindex, peerid, reason);
-        dco->dco_meesage_peer_id = peerid;
+        dco->dco_message_peer_id = peerid;
         dco->dco_del_peer_reason = reason;
         dco->dco_message_type = OVPN_CMD_DEL_PEER;
 
@@ -788,7 +788,7 @@ static int ovpn_handle_msg(struct nl_msg *msg, void *arg)
         }
         buf_init(&dco->dco_packet_in, 0);
         buf_write(&dco->dco_packet_in, data, len);
-        dco->dco_meesage_peer_id = peerid;
+        dco->dco_message_peer_id = peerid;
         dco->dco_message_type = OVPN_CMD_PACKET;
         break;
     }
src/openvpn/dco_linux.h +1 -1
index 94e1a522..61d07a55 100644
@@ -51,7 +51,7 @@ typedef struct
     struct buffer dco_packet_in;
 
     int dco_message_type;
-    int dco_meesage_peer_id;
+    int dco_message_peer_id;
     int dco_del_peer_reason;
 
 } dco_context_t;
src/openvpn/multi.c +3 -3
index cf44dd58..30489038 100644
@@ -3124,7 +3124,7 @@ static void
 process_incoming_dco_packet(struct multi_context *m, struct multi_instance *mi,  dco_context_t *dco)
 {
     struct buffer orig_buf = mi->context.c2.buf;
-    int peer_id = dco->dco_meesage_peer_id;
+    int peer_id = dco->dco_message_peer_id;
 
     mi->context.c2.buf = dco->dco_packet_in;
 
@@ -3184,7 +3184,7 @@ multi_process_incoming_dco(struct multi_context *m)
 
     int ret = dco_do_read(&m->top.c1.tuntap->dco);
 
-    int peer_id = dco->dco_meesage_peer_id;
+    int peer_id = dco->dco_message_peer_id;
 
     if ((peer_id >= 0) && (peer_id < m->max_clients) && (m->instances[peer_id]))
     {
@@ -3204,7 +3204,7 @@ multi_process_incoming_dco(struct multi_context *m)
     }
 
     dco->dco_message_type = 0;
-    dco->dco_meesage_peer_id = -1;
+    dco->dco_message_peer_id = -1;
     return ret > 0;
 }
 #endif
Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/3 open_tun_generic(): Do not consider open_tun_dco() returning 0 to be an error

In reply to Kristof Provost

From: Kristof Provost <[email protected]...>

It seems clear that the intent here is to special case the EEXIST error, not the consider anything else (i.e. 0) to also be an error.

---
 src/openvpn/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/tun.c +1 -1
index f9ba3858..d8f2dea7 100644
@@ -1841,7 +1841,7 @@ open_tun_generic(const char *dev, const char *dev_type, const char *dev_node,
                         dynamic_name);
                     tt->persistent_if = true;
                 }
-                else
+                else if (ret != 0)
                 {
                     msg(M_ERR, "Cannot open TUN/TAP dev %s: %d", dynamic_name, ret);
                 }
Signature · 1 line
2.35.1
#3 lore raw

PATCH 3/3 dco: Check for ipi_addr before using it

In reply to Kristof Provost

From: Kristof Provost <[email protected]...>

If IP_RECVDSTADDR exists we'll define ENABLE_IP_PKTINFO, but that doesn't actually mean we have struct in_pktinfo. We need to check HAVE_IN_PKTINFO for that.

This fixes DCO builds on FreeBSD.

---
 src/openvpn/dco.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/dco.c +1 -1
index 0ce03664..4234bb22 100644
@@ -44,7 +44,7 @@ static bool
 dco_multi_get_localaddr(struct multi_context *m, struct multi_instance *mi,
                         struct sockaddr_storage *local)
 {
-#if ENABLE_IP_PKTINFO
+#if ENABLE_IP_PKTINFO && defined(HAVE_IN_PKTINFO)
     struct context *c = &mi->context;
 
     if (!(c->options.sockflags & SF_USE_IP_PKTINFO))
Signature · 1 line
2.35.1