]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD/MEDIUM: tcp: set-mark support for OpenBSD
authorDavid Carlier <devnexen@gmail.com>
Sat, 3 Jul 2021 09:15:15 +0000 (10:15 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 5 Jul 2021 08:53:18 +0000 (10:53 +0200)
set-mark support for this platform, for routing table purpose.
Follow-up from f7f53afcf9d367d19, this time for OpenBSD.

doc/configuration.txt
include/haproxy/connection.h
src/tcp_act.c

index 5d1c97bd35f7ad163508f4f1737908ec2156b7ab..51f65ae9d9202cb7e795104efcc17a12e69d0f68 100644 (file)
@@ -6510,7 +6510,8 @@ http-request set-mark <mark> [ { if | unless } <condition> ]
   both in decimal or hexadecimal format (prefixed by "0x").
   This can be useful to force certain packets to take a different route (for
   example a cheaper network path for bulk downloads). This works on Linux
-  kernels 2.6.32 and above and requires admin privileges, as well on FreeBSD.
+  kernels 2.6.32 and above and requires admin privileges, as well on FreeBSD
+  and OpenBSD.
 
 http-request set-method <fmt> [ { if | unless } <condition> ]
 
@@ -7171,7 +7172,8 @@ http-response set-mark <mark> [ { if | unless } <condition> ]
   It can be expressed both in decimal or hexadecimal format (prefixed by "0x").
   This can be useful to force certain packets to take a different route (for
   example a cheaper network path for bulk downloads). This works on Linux
-  kernels 2.6.32 and above and requires admin privileges, as well on FreeBSD.
+  kernels 2.6.32 and above and requires admin privileges, as well on FreeBSD
+  and OpenBSD.
 
 http-response set-nice <nice> [ { if | unless } <condition> ]
 
@@ -11908,7 +11910,7 @@ tcp-request connection <action> [{if | unless} <condition>]
       "0x"). This can be useful to force certain packets to take a different
       route (for example a cheaper network path for bulk downloads). This works
       on Linux kernels 2.6.32 and above and requires admin privileges, as well
-      on FreeBSD.
+      on FreeBSD and OpenBSD.
 
     - set-src <expr> :
       Is used to set the source IP address to the value of specified
index 02096b036680c43252068ed6340346f2abad0dea..d28837886b4eec63bb2afc86e1507fa7ba5dc7f6 100644 (file)
@@ -699,6 +699,8 @@ static inline void conn_set_mark(const struct connection *conn, int mark)
 #elif defined(SO_USER_COOKIE)
        uint32_t mval = (uint32_t)mark;
        setsockopt(conn->handle.fd, SOL_SOCKET, SO_USER_COOKIE, &mval, sizeof(mval));
+#elif defined(SO_RTABLE)
+       setsockopt(conn->handle.fd, SOL_SOCKET, SO_RTABLE, &mark, sizeof(mark));
 #endif
 }
 
index b684bff4303890ddf006bff218a11a7dd7b6ed03..3596d312540d3eef33cbed0d90bf12e370329ecb 100644 (file)
@@ -237,7 +237,7 @@ static enum act_return tcp_exec_action_silent_drop(struct act_rule *rule, struct
 }
 
 
-#if defined(SO_MARK) || defined(SO_USER_COOKIE)
+#if defined(SO_MARK) || defined(SO_USER_COOKIE) || defined(SO_RTABLE)
 static enum act_return tcp_action_set_mark(struct act_rule *rule, struct proxy *px,
                                           struct session *sess, struct stream *s, int flags)
 {
@@ -308,7 +308,7 @@ static enum act_parse_ret tcp_parse_set_src_dst(const char **args, int *orig_arg
 static enum act_parse_ret tcp_parse_set_mark(const char **args, int *cur_arg, struct proxy *px,
                                             struct act_rule *rule, char **err)
 {
-#if defined(SO_MARK) || defined(SO_USER_COOKIE)
+#if defined(SO_MARK) || defined(SO_USER_COOKIE) || defined(SO_RTABLE)
        char *endp;
        unsigned int mark;
 
@@ -331,7 +331,7 @@ static enum act_parse_ret tcp_parse_set_mark(const char **args, int *cur_arg, st
        global.last_checks |= LSTCHK_NETADM;
        return ACT_RET_PRS_OK;
 #else
-       memprintf(err, "not supported on this platform (SO_MARK|SO_USER_COOKIE undefined)");
+       memprintf(err, "not supported on this platform (SO_MARK|SO_USER_COOKIE|SO_RTABLE undefined)");
        return ACT_RET_PRS_ERR;
 #endif
 }