Welcome! Log In Create A New Profile

Advanced

[PATCH 1 of 4] Core: added socket protocol

Dourov Maxime
April 18, 2024 10:00AM
# HG changeset patch
# User maxime <mux99@live.be>
# Date 1713355365 -7200
# Wed Apr 17 14:02:45 2024 +0200
# Node ID b7cbe9281f9d6911fd40a894ebc4ac2d701d8fa4
# Parent 49dce50fad40bf09db81ca2a35983ecd7b740e43
Core: added socket protocol.

This patch updates the creation of listening sockets to use a new field
of the `ngx_listening_s` structure. The `protocol` field can be used in
conjunction with the `type` to specify the protocol to be used.

Modules will then be able to specify a different protocol, e.g.
IPPROTO_MPTCP.

diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -487,9 +487,20 @@ ngx_open_listening_sockets(ngx_cycle_t *
continue;
}

- s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, 0);
+ s = (ngx_socket_t) -1;
+ if (ls[i].protocol > 0) {
+ s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type,
+ ls[i].protocol);
+ /* In case of error, retry with the default protocol */
+ ngx_log_error(NGX_LOG_NOTICE, log, 0,
+ "socket(%d) failed, trying with 0", ls[i].protocol);
+ }

if (s == (ngx_socket_t) -1) {
+ s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, 0);
+ }
+
+ if (s == (ngx_socket_t) -1) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
ngx_socket_n " %V failed", &ls[i].addr_text);
return NGX_ERROR;
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -24,6 +24,7 @@ struct ngx_listening_s {
ngx_str_t addr_text;

int type;
+ int protocol;

int backlog;
int rcvbuf;
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 1 of 4] Core: added socket protocol

Dourov Maxime 284 April 18, 2024 10:00AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 179
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready