]> git.feebdaed.xyz Git - 0xmirror/nginx.git/commitdiff
Stream: the "setfib" parameter of the "listen" directive.
authorSergey Kandaurov <pluknet@nginx.com>
Fri, 22 Mar 2024 10:53:19 +0000 (14:53 +0400)
committerSergey Kandaurov <pluknet@nginx.com>
Fri, 22 Mar 2024 10:53:19 +0000 (14:53 +0400)
The FreeBSD SO_SETFIB support.

src/stream/ngx_stream.c
src/stream/ngx_stream.h
src/stream/ngx_stream_core_module.c

index e0879d092568f5583d71b77a7e7c0bee39563c3a..b6eeb23af31070f32208702b7018dbe2c75a4be1 100644 (file)
@@ -1033,6 +1033,10 @@ ngx_stream_add_listening(ngx_conf_t *cf, ngx_stream_conf_addr_t *addr)
     ls->ipv6only = addr->opt.ipv6only;
 #endif
 
+#if (NGX_HAVE_SETFIB)
+    ls->setfib = addr->opt.setfib;
+#endif
+
 #if (NGX_HAVE_TCP_FASTOPEN)
     ls->fastopen = addr->opt.fastopen;
 #endif
index 888715888e1859bb21bc9d377e703f7c685c4d73..dc05dc5bac61e28da1b9f56d2fde41e95addaa9c 100644 (file)
@@ -62,6 +62,9 @@ typedef struct {
     int                            rcvbuf;
     int                            sndbuf;
     int                            type;
+#if (NGX_HAVE_SETFIB)
+    int                            setfib;
+#endif
 #if (NGX_HAVE_TCP_FASTOPEN)
     int                            fastopen;
 #endif
index df08208a78f64faf9e8833b7d249195d45563b6a..576a2fb160ee26e161c9fb75a01f274125a3cbe3 100644 (file)
@@ -920,6 +920,9 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     lsopt.type = SOCK_STREAM;
     lsopt.rcvbuf = -1;
     lsopt.sndbuf = -1;
+#if (NGX_HAVE_SETFIB)
+    lsopt.setfib = -1;
+#endif
 #if (NGX_HAVE_TCP_FASTOPEN)
     lsopt.fastopen = -1;
 #endif
@@ -949,6 +952,22 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
             continue;
         }
 
+#if (NGX_HAVE_SETFIB)
+        if (ngx_strncmp(value[i].data, "setfib=", 7) == 0) {
+            lsopt.setfib = ngx_atoi(value[i].data + 7, value[i].len - 7);
+            lsopt.set = 1;
+            lsopt.bind = 1;
+
+            if (lsopt.setfib == NGX_ERROR) {
+                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                                   "invalid setfib \"%V\"", &value[i]);
+                return NGX_CONF_ERROR;
+            }
+
+            continue;
+        }
+#endif
+
 #if (NGX_HAVE_TCP_FASTOPEN)
         if (ngx_strncmp(value[i].data, "fastopen=", 9) == 0) {
             lsopt.fastopen = ngx_atoi(value[i].data + 9, value[i].len - 9);