Change in openvpn[master]: mroute: properly print protocol at the end of the string
A message that is not in the archive (sent off-list or not yet received): gerrit.1727098847000.Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
to review the following change.
Change subject: mroute: properly print protocol at the end of the string
......................................................................
mroute: properly print protocol at the end of the string
mroute: substitute unused field with proto
Rather than adding a new field 'proto', take advantage of the 'unused' field and rename it.
Hashing will now start at the 'proto' field rather than 'type'.
MULTI: ensure we've got the correct protocol with virtual addresses
MULTI: ensure we've got the same value as protocol for vaddresses
---
M src/openvpn/forward.c
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
6 files changed, 27 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/1
src/openvpn/forward.c +9 -6
@@ -1129,13 +1129,16 @@ decrypt_status =openvpn_decrypt (&c->c2.buf, c->c2.buffers->decrypt_buf, co, &c->c2.frame, ad_start); -if (!decrypt_status -/* all sockets are of the same type, so just check the first one */ - &&link_socket_connection_oriented (c->c2.link_sockets[0 ])) +for (int i =0 ; i < c->c1.link_sockets_num; i++) { -/* decryption errors are fatal in TCP mode */ -register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ -msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); +if (!decrypt_status +/* all sockets are of the same type, so just check the first one (not anymore!) */ + &&link_socket_connection_oriented (c->c2.link_sockets[i])) + { +/* decryption errors are fatal in TCP mode */ +register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ +msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); + } } }else
src/openvpn/mroute.c +1 -1
@@ -421,7 +421,6 @@ {buf_printf (&out,":%d" ,ntohs (maddr.v4.port)); } -buf_printf (&out,":%d" , maddr.proto); }break ;
@@ -454,6 +453,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +2 -3
@@ -74,9 +74,8 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; -uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t proto; +uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */ union {
@@ -221,7 +220,7 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; } static inline uint32_t
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi && !proto_is_dgram (ls->info.proto)) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +1 -0
@@ -193,6 +193,7 @@struct multi_instance *mi =NULL ;struct hash *hash = m->hash; real.proto = ls->info.proto; + m->local.proto = real.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +13 -2
@@ -1156,11 +1156,12 @@*/ static struct multi_instance *multi_get_instance_by_virtual_addr (struct multi_context *m, -const struct mroute_addr *addr, +struct mroute_addr *addr,bool cidr_routing) {struct multi_route *route;struct multi_instance *ret =NULL ; + addr->proto =0 ;/* check for local address */ if (mroute_addr_equal (addr, &m->local))
@@ -1246,6 +1247,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3346,6 +3348,14 @@bool ret = true;bool floated = false; +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to void hashing insert +* and search issues. +*/ + src.proto =0 ; + dest.proto = src.proto; +if (m->pending) {return true;
@@ -3412,7 +3422,6 @@0 , &c->c2.to_tun, DEV_TYPE_TUN); -/* drop packet if extract failed */ if (!(mroute_flags &MROUTE_EXTRACT_SUCCEEDED )) {
@@ -3550,6 +3559,8 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; + src.proto =0 ; + dest.proto = src.proto;#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, its_Giaan, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: properly print protocol at the end of the string
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
Patchset:
PS1:
This definitely needs a commit message with a better Subject line (first line) - now git whill show "properly print protocol", which is just a small aspect of "a bunch of mroute changes"
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 25 Sep 2024 07:11:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: cron2, flichtenheld, its_Giaan, plaisthos.
ordex has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: properly print protocol at the end of the string
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Quoted 1 line
This definitely needs a commit message with a better Subject line (first line) - now git whill show […]
I think here there was some fixup/squash mess.
Commit message definitely needs some love <3.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 25 Sep 2024 11:56:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Gerrit-MessageType: comment
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, its_Giaan, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
M src/openvpn/forward.c
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
6 files changed, 27 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/2
src/openvpn/forward.c +9 -6
@@ -1130,13 +1130,16 @@ decrypt_status =openvpn_decrypt (&c->c2.buf, c->c2.buffers->decrypt_buf, co, &c->c2.frame, ad_start); -if (!decrypt_status -/* all sockets are of the same type, so just check the first one */ - &&link_socket_connection_oriented (c->c2.link_sockets[0 ])) +for (int i =0 ; i < c->c1.link_sockets_num; i++) { -/* decryption errors are fatal in TCP mode */ -register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ -msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); +if (!decrypt_status +/* all sockets are of the same type, so just check the first one (not anymore!) */ + &&link_socket_connection_oriented (c->c2.link_sockets[i])) + { +/* decryption errors are fatal in TCP mode */ +register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ +msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); + } } }else
src/openvpn/mroute.c +1 -1
@@ -421,7 +421,6 @@ {buf_printf (&out,":%d" ,ntohs (maddr.v4.port)); } -buf_printf (&out,":%d" , maddr.proto); }break ;
@@ -454,6 +453,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +2 -3
@@ -74,9 +74,8 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; -uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t proto; +uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */ union {
@@ -221,7 +220,7 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; } static inline uint32_t
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , sock);if (mi && !proto_is_dgram (sock->info.proto)) { + mi->real.proto = sock->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +1 -0
@@ -193,6 +193,7 @@struct multi_instance *mi =NULL ;struct hash *hash = m->hash; real.proto = sock->info.proto; + m->local.proto = real.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +13 -2
@@ -1156,11 +1156,12 @@*/ static struct multi_instance *multi_get_instance_by_virtual_addr (struct multi_context *m, -const struct mroute_addr *addr, +struct mroute_addr *addr,bool cidr_routing) {struct multi_route *route;struct multi_instance *ret =NULL ; + addr->proto =0 ;/* check for local address */ if (mroute_addr_equal (addr, &m->local))
@@ -1246,6 +1247,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3346,6 +3348,14 @@bool ret = true;bool floated = false; +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to void hashing insert +* and search issues. +*/ + src.proto =0 ; + dest.proto = src.proto; +if (m->pending) {return true;
@@ -3412,7 +3422,6 @@0 , &c->c2.to_tun, DEV_TYPE_TUN); -/* drop packet if extract failed */ if (!(mroute_flags &MROUTE_EXTRACT_SUCCEEDED )) {
@@ -3550,6 +3559,8 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; + src.proto =0 ; + dest.proto = src.proto;#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, ordex, plaisthos.
its_Giaan has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
Patch Set 2:
(1 comment)
Patchset:
PS1:
Quoted 1 line
I think here there was some fixup/squash mess. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Tue, 01 Oct 2024 15:32:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Gerrit-MessageType: comment
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, ordex, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
to look at the new patch set (#3).
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
M src/openvpn/forward.c
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
6 files changed, 28 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/3
src/openvpn/forward.c +9 -6
@@ -1130,13 +1130,16 @@ decrypt_status =openvpn_decrypt (&c->c2.buf, c->c2.buffers->decrypt_buf, co, &c->c2.frame, ad_start); -if (!decrypt_status -/* all sockets are of the same type, so just check the first one */ - &&link_socket_connection_oriented (c->c2.link_sockets[0 ])) +for (int i =0 ; i < c->c1.link_sockets_num; i++) { -/* decryption errors are fatal in TCP mode */ -register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ -msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); +if (!decrypt_status +/* all sockets are of the same type, so just check the first one (not anymore!) */ + &&link_socket_connection_oriented (c->c2.link_sockets[i])) + { +/* decryption errors are fatal in TCP mode */ +register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ +msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); + } } }else
src/openvpn/mroute.c +1 -0
@@ -453,6 +453,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +2 -2
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -216,7 +216,7 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; } static inline uint32_t
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , sock);if (mi) { + mi->real.proto = sock->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +2 -0
@@ -192,6 +192,8 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = sock->info.proto; + m->local.proto = real.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +13 -2
@@ -1157,11 +1157,12 @@*/ static struct multi_instance *multi_get_instance_by_virtual_addr (struct multi_context *m, -const struct mroute_addr *addr, +struct mroute_addr *addr,bool cidr_routing) {struct multi_route *route;struct multi_instance *ret =NULL ; + addr->proto =0 ;/* check for local address */ if (mroute_addr_equal (addr, &m->local))
@@ -1247,6 +1248,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3347,6 +3349,14 @@bool ret = true;bool floated = false; +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to void hashing insert +* and search issues. +*/ + src.proto =0 ; + dest.proto = src.proto; +if (m->pending) {return true;
@@ -3413,7 +3423,6 @@0 , &c->c2.to_tun, DEV_TYPE_TUN); -/* drop packet if extract failed */ if (!(mroute_flags &MROUTE_EXTRACT_SUCCEEDED )) {
@@ -3551,6 +3560,8 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; + src.proto =0 ; + dest.proto = src.proto;#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, ordex, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
to look at the new patch set (#7).
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
M src/openvpn/forward.c
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
6 files changed, 28 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/7
src/openvpn/forward.c +9 -6
@@ -1129,13 +1129,16 @@ decrypt_status =openvpn_decrypt (&c->c2.buf, c->c2.buffers->decrypt_buf, co, &c->c2.frame, ad_start); -if (!decrypt_status -/* on the instance context we have only one socket, so just check the first one */ - &&link_socket_connection_oriented (c->c2.link_sockets[0 ])) +for (int i =0 ; i < c->c1.link_sockets_num; i++) { -/* decryption errors are fatal in TCP mode */ -register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ -msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); +if (!decrypt_status +/* all sockets are of the same type, so just check the first one (not anymore!) */ + &&link_socket_connection_oriented (c->c2.link_sockets[i])) + { +/* decryption errors are fatal in TCP mode */ +register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ +msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); + } } }else
src/openvpn/mroute.c +1 -0
@@ -453,6 +453,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +2 -2
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -216,7 +216,7 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; } static inline uint32_t
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , sock);if (mi) { + mi->real.proto = sock->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +2 -0
@@ -192,6 +192,8 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = sock->info.proto; + m->local.proto = real.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +13 -2
@@ -1153,11 +1153,12 @@*/ static struct multi_instance *multi_get_instance_by_virtual_addr (struct multi_context *m, -const struct mroute_addr *addr, +struct mroute_addr *addr,bool cidr_routing) {struct multi_route *route;struct multi_instance *ret =NULL ; + addr->proto =0 ;/* check for local address */ if (mroute_addr_equal (addr, &m->local))
@@ -1243,6 +1244,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3343,6 +3345,14 @@bool ret = true;bool floated = false; +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to void hashing insert +* and search issues. +*/ + src.proto =0 ; + dest.proto = src.proto; +if (m->pending) {return true;
@@ -3409,7 +3419,6 @@0 , &c->c2.to_tun, DEV_TYPE_TUN); -/* drop packet if extract failed */ if (!(mroute_flags &MROUTE_EXTRACT_SUCCEEDED )) {
@@ -3547,6 +3556,8 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; + src.proto =0 ; + dest.proto = src.proto;#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 7
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, ordex, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
to look at the new patch set (#12).
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
M src/openvpn/forward.c
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
6 files changed, 28 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/12
src/openvpn/forward.c +9 -6
@@ -1129,13 +1129,16 @@ decrypt_status =openvpn_decrypt (&c->c2.buf, c->c2.buffers->decrypt_buf, co, &c->c2.frame, ad_start); -if (!decrypt_status -/* on the instance context we have only one socket, so just check the first one */ - &&link_socket_connection_oriented (c->c2.link_sockets[0 ])) +for (int i =0 ; i < c->c1.link_sockets_num; i++) { -/* decryption errors are fatal in TCP mode */ -register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ -msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); +if (!decrypt_status +/* all sockets are of the same type, so just check the first one (not anymore!) */ + &&link_socket_connection_oriented (c->c2.link_sockets[i])) + { +/* decryption errors are fatal in TCP mode */ +register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ +msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); + } } }else
src/openvpn/mroute.c +1 -0
@@ -453,6 +453,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +2 -2
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -216,7 +216,7 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; } static inline uint32_t
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +2 -0
@@ -192,6 +192,8 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = ls->info.proto; + m->local.proto = real.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +13 -2
@@ -1153,11 +1153,12 @@*/ static struct multi_instance *multi_get_instance_by_virtual_addr (struct multi_context *m, -const struct mroute_addr *addr, +struct mroute_addr *addr,bool cidr_routing) {struct multi_route *route;struct multi_instance *ret =NULL ; + addr->proto =0 ;/* check for local address */ if (mroute_addr_equal (addr, &m->local))
@@ -1243,6 +1244,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3344,6 +3346,14 @@bool ret = true;bool floated = false; +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to void hashing insert +* and search issues. +*/ + src.proto =0 ; + dest.proto = src.proto; +if (m->pending) {return true;
@@ -3410,7 +3420,6 @@0 , &c->c2.to_tun, DEV_TYPE_TUN); -/* drop packet if extract failed */ if (!(mroute_flags &MROUTE_EXTRACT_SUCCEEDED )) {
@@ -3548,6 +3557,8 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; + src.proto =0 ; + dest.proto = src.proto;#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 12
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, ordex, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
to look at the new patch set (#14).
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
M src/openvpn/forward.c
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
6 files changed, 28 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/14
src/openvpn/forward.c +9 -6
@@ -1129,13 +1129,16 @@ decrypt_status =openvpn_decrypt (&c->c2.buf, c->c2.buffers->decrypt_buf, co, &c->c2.frame, ad_start); -if (!decrypt_status -/* on the instance context we have only one socket, so just check the first one */ - &&link_socket_connection_oriented (c->c2.link_sockets[0 ])) +for (int i =0 ; i < c->c1.link_sockets_num; i++) { -/* decryption errors are fatal in TCP mode */ -register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ -msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); +if (!decrypt_status +/* on the instance context we have only one socket, so just check the first one */ + &&link_socket_connection_oriented (c->c2.link_sockets[i])) + { +/* decryption errors are fatal in TCP mode */ +register_signal (c->sig,SIGUSR1 ,"decryption-error" );/* SOFT-SIGUSR1 -- decryption error in TCP mode */ +msg (D_STREAM_ERRORS ,"Fatal decryption error (process_incoming_link), restarting" ); + } } }else
src/openvpn/mroute.c +1 -0
@@ -454,6 +454,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +2 -2
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -216,7 +216,7 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; } static inline uint32_t
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +2 -0
@@ -192,6 +192,8 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = ls->info.proto; + m->local.proto = real.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +13 -2
@@ -1153,11 +1153,12 @@*/ static struct multi_instance *multi_get_instance_by_virtual_addr (struct multi_context *m, -const struct mroute_addr *addr, +struct mroute_addr *addr,bool cidr_routing) {struct multi_route *route;struct multi_instance *ret =NULL ; + addr->proto =0 ;/* check for local address */ if (mroute_addr_equal (addr, &m->local))
@@ -1243,6 +1244,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3344,6 +3346,14 @@bool ret = true;bool floated = false; +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to void hashing insert +* and search issues. +*/ + src.proto =0 ; + dest.proto = src.proto; +if (m->pending) {return true;
@@ -3410,7 +3420,6 @@0 , &c->c2.to_tun, DEV_TYPE_TUN); -/* drop packet if extract failed */ if (!(mroute_flags &MROUTE_EXTRACT_SUCCEEDED )) {
@@ -3548,6 +3557,8 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; + src.proto =0 ; + dest.proto = src.proto;#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 14
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
Patch Set 14: Code-Review-2
(8 comments)
Patchset:
PS14:
There is a couple of things that need looking at
- the forward.c hunk should go to a patch in the series that actually deals with socket arrays, and also very very closely checked for correctness
- the proto initialization in the maddr could be done in a more elegant way
- mroute_addr_hash_len() needs to be fixed
File src/openvpn/forward.c:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/3e5d8af2_a31c87b9 :
PS14, Line 1132: for (int i = 0; i < c->c1.link_sockets_num; i++)
I assume this hunk is needed, but it's sort of "outside the scope of mroute handling" (so should either move to #764 or be mentioned in the commit message - I think "moving" is more reasonable).
Also I am not sure it is *correct* - if I read this correctly, the effect is now
if (!decrypt_status && we have *any* listening TCP socket) { SIGUSR1; }
no? As it's walking the whole array, not checking the socket where this packet was received.
http://gerrit.openvpn.net/c/openvpn/+/765/comment/35afcb51_f6ae0b38 :
PS14, Line 1135: /* on the instance context we have only one socket, so just check the first one */
whatever the outcome is, this comment is no longer correct :-)
File src/openvpn/mroute.h:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/cad156ad_89f96d93 :
PS14, Line 225: return (uint32_t) a->len + 2;
if you change the start of the to-be-hashed block, but all the existing data should still be hashed, this looks like you also must increase the length by +1?
File src/openvpn/mudp.c:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/7a2c3469_2b108655 :
PS14, Line 196: m->local.proto = real.proto;
This is a bit confusing. I can see the assignment to real.proto (because mroute_extract_openvpn_sockaddr() cannot do it) but what is m->local, and who is poulating the rest of it?
File src/openvpn/multi.c:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/ff5809d5_e5708d45 :
PS14, Line 1156: struct mroute_addr *addr,
this looks wrong. A lookup function should not modify its arguments.
I see calls to multi_get_instance_by_virtual_addr() being prepared by mroute_extract_addr_from_packet() calls - so if that function sets proto = 0 (or just CLEAR()s the mroutes) we do not need to do anything here.
http://gerrit.openvpn.net/c/openvpn/+/765/comment/8164b377_9ec4fcaa :
PS14, Line 3356:
see comment above - now you're actually setting proto in the caller, even if I do not agree this is the right place - so the change to multi_get_instance_by_virtual_addr() is definitely not needed.
I'd still move this into mroute_extract_addr_from_packet(), with the comment.
http://gerrit.openvpn.net/c/openvpn/+/765/comment/81dba5d2_42f25dc3 :
PS14, Line 3561: dest.proto = src.proto;
same thing -> mroute_extract_addr_from_packet()
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 14
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 24 Jan 2025 08:00:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
to look at the new patch set (#15).
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
5 files changed, 17 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/15
src/openvpn/mroute.c +1 -0
@@ -454,6 +454,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +12 -3
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -183,6 +183,15 @@ {unsigned int ret =0 ;verify_align_4 (buf); + +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to avoid hashing insert +* and search issues. +*/ + src->proto =0 ; + dest->proto = src->proto; +if (tunnel_type ==DEV_TYPE_TUN ) { ret =mroute_extract_addr_ip (src, dest, buf);
@@ -216,13 +225,13 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; }static inline uint32_t mroute_addr_hash_len (const struct mroute_addr *a) { -return (uint32_t ) a->len +2 ; +return (uint32_t ) a->len +3 ; } static inline void
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +1 -0
@@ -192,6 +192,7 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = ls->info.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +2 -3
@@ -1153,7 +1153,7 @@*/ static struct multi_instance *multi_get_instance_by_virtual_addr (struct multi_context *m, -const struct mroute_addr *addr, +struct mroute_addr *addr,bool cidr_routing) {struct multi_route *route;
@@ -1243,6 +1243,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3410,7 +3411,6 @@0 , &c->c2.to_tun, DEV_TYPE_TUN); -/* drop packet if extract failed */ if (!(mroute_flags &MROUTE_EXTRACT_SUCCEEDED )) {
@@ -3548,7 +3548,6 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; -#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 15
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, ordex, plaisthos.
its_Giaan has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
Patch Set 15:
(7 comments)
File src/openvpn/forward.c:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/7d7d6798_7dba137c :
PS14, Line 1132: for (int i = 0; i < c->c1.link_sockets_num; i++)
Quoted 1 line
I assume this hunk is needed, but it's sort of "outside the scope of mroute handling" (so should eit […]
This is still about client context, so no need to loop and no need to touch this again.
http://gerrit.openvpn.net/c/openvpn/+/765/comment/4c321545_89555b0c :
PS14, Line 1135: /* on the instance context we have only one socket, so just check the first one */
Quoted 1 line
whatever the outcome is, this comment is no longer correct :-)
Done
File src/openvpn/mroute.h:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/9bb3a8db_d8b619b4 :
PS14, Line 225: return (uint32_t) a->len + 2;
Quoted 1 line
if you change the start of the to-be-hashed block, but all the existing data should still be hashed, […]
Done
File src/openvpn/mudp.c:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/ff1ec800_dab6a655 :
PS14, Line 196: m->local.proto = real.proto;
Quoted 1 line
This is a bit confusing. I can see the assignment to `real. […]
That's a leftover, I see that m->local is used only on virtual addresses context so no need to copy the real proto and since it's CLEAR() no need to set the proto to 0.
File src/openvpn/multi.c:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/f9fda981_a1023801 :
PS14, Line 1156: struct mroute_addr *addr,
Quoted 1 line
this looks wrong. A lookup function should not modify its arguments. […]
Done
http://gerrit.openvpn.net/c/openvpn/+/765/comment/285a38d0_93d7ac29 :
PS14, Line 3356:
Quoted 1 line
see comment above - now you're actually setting
protoin the caller, even if I do not agree this i […]
Done
http://gerrit.openvpn.net/c/openvpn/+/765/comment/9738102a_e71eb117 :
PS14, Line 3561: dest.proto = src.proto;
Quoted 1 line
same thing ->
mroute_extract_addr_from_packet()
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 15
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 24 Jan 2025 11:48:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Gerrit-MessageType: comment
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
Patch Set 15: Code-Review-1
(3 comments)
Patchset:
PS15:
Upgrade to -1 ;-) - mostly this is fine, but we still lost a "const" argument, and there is a spurious blank line removal
File src/openvpn/multi.c:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/6724d969_5ff543ed :
PS15, Line 3413:
spurious deletion of this blank line? don't :-)
http://gerrit.openvpn.net/c/openvpn/+/765/comment/ee36f236_30cdf224 :
PS15, Line 1156: struct mroute_addr *addr,
please bring the "const" back...
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 15
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 24 Jan 2025 12:47:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, its_Giaan, ordex, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
to look at the new patch set (#16).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
5 files changed, 16 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/16
src/openvpn/mroute.c +1 -0
@@ -454,6 +454,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +12 -3
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -183,6 +183,15 @@ {unsigned int ret =0 ;verify_align_4 (buf); + +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to avoid hashing insert +* and search issues. +*/ + src->proto =0 ; + dest->proto = src->proto; +if (tunnel_type ==DEV_TYPE_TUN ) { ret =mroute_extract_addr_ip (src, dest, buf);
@@ -216,13 +225,13 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; }static inline uint32_t mroute_addr_hash_len (const struct mroute_addr *a) { -return (uint32_t ) a->len +2 ; +return (uint32_t ) a->len +3 ; } static inline void
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +1 -0
@@ -192,6 +192,7 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = ls->info.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +1 -1
@@ -1243,6 +1243,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3548,7 +3549,6 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; -#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 16
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: cron2, flichtenheld, ordex, plaisthos.
its_Giaan has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
Patch Set 16:
(2 comments)
File src/openvpn/multi.c:
http://gerrit.openvpn.net/c/openvpn/+/765/comment/63b6b639_1e4d46fc :
PS15, Line 3413:
Quoted 1 line
spurious deletion of this blank line? don't :-)
Done
http://gerrit.openvpn.net/c/openvpn/+/765/comment/f0994588_93bd3f29 :
PS15, Line 1156: struct mroute_addr *addr,
Quoted 1 line
please bring the "const" back...
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 16
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 24 Jan 2025 14:09:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Gerrit-MessageType: comment
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
Patch Set 16: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 16
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 24 Jan 2025 14:10:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v16 1/1 mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveFrom: Gianmarco De Gregori <[email protected]...>
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/765
This mail reflects revision 16 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/mroute.c +1 -0
@@ -454,6 +454,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +12 -3
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -183,6 +183,15 @@ {unsigned int ret =0 ;verify_align_4 (buf); + +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to avoid hashing insert +* and search issues. +*/ + src->proto =0 ; + dest->proto = src->proto; +if (tunnel_type ==DEV_TYPE_TUN ) { ret =mroute_extract_addr_ip (src, dest, buf);
@@ -216,13 +225,13 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; }static inline uint32_t mroute_addr_hash_len (const struct mroute_addr *a) { -return (uint32_t ) a->len +2 ; +return (uint32_t ) a->len +3 ; } static inline void
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +1 -0
@@ -192,6 +192,7 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = ls->info.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +1 -1
@@ -1243,6 +1243,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3548,7 +3549,6 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; -#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));#endif
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
Patch Set 16: Code-Review-2
(1 comment)
Patchset:
PS16:
"Something is breaking my server side tests", so it seems - after a first successful TCP connect, the server aborts:
Jan 24 15:22:31 gentoo tun-tcp-p2mp[30385]: Assertion failed at multi.c:636 Jan 24 15:22:31 gentoo tun-tcp-p2mp[30385]: Exiting due to fatal error
(just recording here, as Gian has signalled "I already found the problem")
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 16
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 24 Jan 2025 15:37:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
to look at the new patch set (#17).
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
5 files changed, 21 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/17
src/openvpn/mroute.c +1 -0
@@ -454,6 +454,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +16 -3
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -183,6 +183,15 @@ {unsigned int ret =0 ;verify_align_4 (buf); + +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to avoid hashing insert +* and search issues. +*/ + src->proto =0 ; + dest->proto = src->proto; +if (tunnel_type ==DEV_TYPE_TUN ) { ret =mroute_extract_addr_ip (src, dest, buf);
@@ -201,6 +210,10 @@ {return false; } +if (a1->proto != a2->proto) + { +return false; + }if (a1->netbits != a2->netbits) {return false;
@@ -216,13 +229,13 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; }static inline uint32_t mroute_addr_hash_len (const struct mroute_addr *a) { -return (uint32_t ) a->len +2 ; +return (uint32_t ) a->len +3 ; } static inline void
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +1 -0
@@ -192,6 +192,7 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = ls->info.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +2 -1
@@ -794,6 +794,7 @@ { goto err; } + mi->real.proto = ls->info.proto;generate_prefix (mi); }
@@ -1243,6 +1244,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3548,7 +3550,6 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; -#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 17
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveAttention is currently required from: flichtenheld, its_Giaan, ordex, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
Patch Set 17: Code-Review+2
(1 comment)
Patchset:
PS17:
Lo and behold, with that change it passes the server side tests just fine ;-)
(Multiple local for the same protocol family lead to multiple bound sockets as well, but it doesn't work correctly yet - this seems to need bits from #764)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 17
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Fri, 24 Jan 2025 20:51:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v17 1/1 mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archiveFrom: Gianmarco De Gregori <[email protected]...>
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/765
This mail reflects revision 17 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/mroute.c +1 -0
@@ -454,6 +454,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +16 -3
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -183,6 +183,15 @@ {unsigned int ret =0 ;verify_align_4 (buf); + +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to avoid hashing insert +* and search issues. +*/ + src->proto =0 ; + dest->proto = src->proto; +if (tunnel_type ==DEV_TYPE_TUN ) { ret =mroute_extract_addr_ip (src, dest, buf);
@@ -201,6 +210,10 @@ {return false; } +if (a1->proto != a2->proto) + { +return false; + }if (a1->netbits != a2->netbits) {return false;
@@ -216,13 +229,13 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; }static inline uint32_t mroute_addr_hash_len (const struct mroute_addr *a) { -return (uint32_t ) a->len +2 ; +return (uint32_t ) a->len +3 ; } static inline void
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +1 -0
@@ -192,6 +192,7 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = ls->info.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +2 -1
@@ -794,6 +794,7 @@ { goto err; } + mi->real.proto = ls->info.proto;generate_prefix (mi); }
@@ -1243,6 +1244,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3548,7 +3550,6 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; -#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));#endif
[Openvpn-devel] [PATCH applied] Re: mroute: adapt to new protocol handling and hashing improvements
This is also basically only "adding infrastructure" - the mroute hashing is used to find a peer based on IP address, and with UDP+TCP sockets in use at the same time, a collision "same remote IP+Port, different proto" is possible.
Now, the hashing is not strictly needed for incoming packets on a TCP connection ("there is only one client on that socket"), but the currently-existing infrastructure is not using the "socket -> mi" shortcut, at least not everywhere (e.g. multi.c: multi_close_instance() which is agnostic on UDP/TCP, and crashed nicely on 765 #v16...).
Thus, we need this ;-)
Stared a lot at this code from v1...v17, Gian/Antonio reworked the patch quite a bit, and the server side testbed found more issues... but now we're at a point where the code looks good and all the test instances are well-behaved. In it goes.
Your patch has been applied to the master branch.
commit dda93f30411eec3457a48e94ef599e3f034c87e5
Author: Gianmarco De Gregori Date: Fri Jan 24 21:51:35 2025 +0100
mroute: adapt to new protocol handling and hashing improvements
Signed-off-by: Gianmarco De Gregori <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30579.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archivecron2 has uploaded a new patch set (#18) to the change originally created by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30579.html
---
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
5 files changed, 21 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/765/18
src/openvpn/mroute.c +1 -0
@@ -454,6 +454,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +16 -3
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -183,6 +183,15 @@ {unsigned int ret =0 ;verify_align_4 (buf); + +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to avoid hashing insert +* and search issues. +*/ + src->proto =0 ; + dest->proto = src->proto; +if (tunnel_type ==DEV_TYPE_TUN ) { ret =mroute_extract_addr_ip (src, dest, buf);
@@ -201,6 +210,10 @@ {return false; } +if (a1->proto != a2->proto) + { +return false; + }if (a1->netbits != a2->netbits) {return false;
@@ -216,13 +229,13 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; }static inline uint32_t mroute_addr_hash_len (const struct mroute_addr *a) { -return (uint32_t ) a->len +2 ; +return (uint32_t ) a->len +3 ; } static inline void
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +1 -0
@@ -192,6 +192,7 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = ls->info.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +2 -1
@@ -794,6 +794,7 @@ { goto err; } + mi->real.proto = ls->info.proto;generate_prefix (mi); }
@@ -1243,6 +1244,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3548,7 +3550,6 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; -#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 18
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-MessageType: newpatchset
[Openvpn-devel] [S] Change in openvpn[master]: mroute: adapt to new protocol handling and hashing improvements
In reply to a message not in the archivecron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/765?usp=email )
Change subject: mroute: adapt to new protocol handling and hashing improvements
......................................................................
mroute: adapt to new protocol handling and hashing improvements
Repurposing an unused field and renaming it to 'proto' instead of introducing a new field. The hashing now begins at the 'proto' field rather than the 'type' field. Additionally, the changes ensure that the correct protocol is consistently used with virtual addresses ensuring alignment.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30579.html
---
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
5 files changed, 21 insertions(+), 4 deletions(-)
src/openvpn/mroute.c +1 -0
@@ -454,6 +454,7 @@buf_printf (&out,"UNKNOWN" );break ; } +buf_printf (&out,"|%d" , maddr.proto);return BSTR (&out); }else
src/openvpn/mroute.h +16 -3
@@ -74,7 +74,7 @@struct mroute_addr {uint8_t len;/* length of address */ -uint8_t unused; +uint8_t proto;uint8_t type;/* MR_ADDR/MR_WITH flags */ uint8_t netbits;/* number of bits in network part of address, * valid if MR_WITH_NETBITS is set */
@@ -183,6 +183,15 @@ {unsigned int ret =0 ;verify_align_4 (buf); + +/* +* Since we don't really need the protocol on vaddresses for internal VPN +* payload packets, make sure we have the same value to avoid hashing insert +* and search issues. +*/ + src->proto =0 ; + dest->proto = src->proto; +if (tunnel_type ==DEV_TYPE_TUN ) { ret =mroute_extract_addr_ip (src, dest, buf);
@@ -201,6 +210,10 @@ {return false; } +if (a1->proto != a2->proto) + { +return false; + }if (a1->netbits != a2->netbits) {return false;
@@ -216,13 +229,13 @@ mroute_addr_hash_ptr(const struct mroute_addr *a) {/* NOTE: depends on ordering of struct mroute_addr */ -return (uint8_t *) &a->type; +return (uint8_t *) &a->proto; }static inline uint32_t mroute_addr_hash_len (const struct mroute_addr *a) { -return (uint32_t ) a->len +2 ; +return (uint32_t ) a->len +3 ; } static inline void
src/openvpn/mtcp.c +1 -0
@@ -56,6 +56,7 @@ mi =multi_create_instance (m,NULL , ls);if (mi) { + mi->real.proto = ls->info.proto;struct hash_element *he;const uint32_t hv =hash_value (hash, &mi->real);struct hash_bucket *bucket =hash_bucket (hash, hv);
src/openvpn/mudp.c +1 -0
@@ -192,6 +192,7 @@struct mroute_addr real = {0 };struct multi_instance *mi =NULL ;struct hash *hash = m->hash; + real.proto = ls->info.proto;if (mroute_extract_openvpn_sockaddr (&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len >0 )
src/openvpn/multi.c +2 -1
@@ -794,6 +794,7 @@ { goto err; } + mi->real.proto = ls->info.proto;generate_prefix (mi); }
@@ -1243,6 +1244,7 @@CLEAR (remote_si); remote_si.addr.in4.sin_family =AF_INET ; remote_si.addr.in4.sin_addr.s_addr =htonl (a); + addr.proto =0 ;ASSERT (mroute_extract_openvpn_sockaddr (&addr, &remote_si, false));if (netbits >=0 )
@@ -3548,7 +3550,6 @@const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap);int16_t vid =0 ; -#ifdef MULTI_DEBUG_EVENT_LOOP printf ("TUN -> TCP/UDP [%d]\n" ,BLEN (&m->top.c2.buf));#endif
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/765?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic66eccb5058fe9c0fae64d8e2ca88728068a92ab
Gerrit-Change-Number: 765
Gerrit-PatchSet: 18
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-MessageType: merged