From: "cron2 (Code Review)" Date: Fri, 8 Mar 2024 11:25:26 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., gianmarco@...2726..., openvpn-devel@lists.sourceforge.net, frank@...2641..., a@...2181... Message-ID: <62646442463d8a7b5fd0126468b3bb07c9e1394e-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="F+97Bx7bgPc="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Minor fix to process_ip_header List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: its_Giaan , plaisthos , flichtenheld Cc: openvpn-devel --F+97Bx7bgPc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#6) to the change originally created by= its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/525?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by flichtenheld, Code-Review+2 by plaisthos Change subject: Minor fix to process_ip_header ...................................................................... Minor fix to process_ip_header Removed if-guard checking if any feature is enabled before performing per-feature check. It doesn't save us much but instead introduces uneeded complexity. While at it, fixed a typo IMCP -> ICMP for defined PIPV6_ICMP_NOHOST_CLIENT and PIPV6_ICMP_NOHOST_SERVER macros. Fixes: Trac https://community.openvpn.net/openvpn/ticket/269 Change-Id: I4b5e8357d872c920efdb64632e9bce72cebee202 Signed-off-by: Gianmarco De Gregori Acked-by: Arne Schwabe Acked-by: Frank Lichtenheld Message-Id: <20240307124616.16358-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28= 345.html Signed-off-by: Gert Doering --- M src/openvpn/forward.c M src/openvpn/forward.h M src/openvpn/multi.c 3 files changed, 49 insertions(+), 61 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/25/525/6 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 0443ca0..556c465 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -1460,7 +1460,7 @@ * us to examine the IP header (IPv4 or IPv6). */ unsigned int flags =3D PIPV4_PASSTOS | PIP_MSSFIX | PIPV4_CLIENT_N= AT - | PIPV6_IMCP_NOHOST_CLIENT; + | PIPV6_ICMP_NOHOST_CLIENT; process_ip_header(c, flags, &c->c2.buf); #ifdef PACKET_TRUNCATION_CHECK @@ -1644,73 +1644,60 @@ } if (!c->options.block_ipv6) { - flags &=3D ~(PIPV6_IMCP_NOHOST_CLIENT | PIPV6_IMCP_NOHOST_SERVER); + flags &=3D ~(PIPV6_ICMP_NOHOST_CLIENT | PIPV6_ICMP_NOHOST_SERVER); } if (buf->len > 0) { - /* - * The --passtos and --mssfix options require - * us to examine the IPv4 header. - */ - - if (flags & (PIP_MSSFIX -#if PASSTOS_CAPABILITY - | PIPV4_PASSTOS -#endif - | PIPV4_CLIENT_NAT - )) + struct buffer ipbuf =3D *buf; + if (is_ipv4(TUNNEL_TYPE(c->c1.tuntap), &ipbuf)) { - struct buffer ipbuf =3D *buf; - if (is_ipv4(TUNNEL_TYPE(c->c1.tuntap), &ipbuf)) - { #if PASSTOS_CAPABILITY - /* extract TOS from IP header */ - if (flags & PIPV4_PASSTOS) - { - link_socket_extract_tos(c->c2.link_socket, &ipbuf); - } + /* extract TOS from IP header */ + if (flags & PIPV4_PASSTOS) + { + link_socket_extract_tos(c->c2.link_socket, &ipbuf); + } #endif - /* possibly alter the TCP MSS */ - if (flags & PIP_MSSFIX) - { - mss_fixup_ipv4(&ipbuf, c->c2.frame.mss_fix); - } - - /* possibly do NAT on packet */ - if ((flags & PIPV4_CLIENT_NAT) && c->options.client_nat) - { - const int direction =3D (flags & PIP_OUTGOING) ? CN_IN= COMING : CN_OUTGOING; - client_nat_transform(c->options.client_nat, &ipbuf, di= rection); - } - /* possibly extract a DHCP router message */ - if (flags & PIPV4_EXTRACT_DHCP_ROUTER) - { - const in_addr_t dhcp_router =3D dhcp_extract_router_ms= g(&ipbuf); - if (dhcp_router) - { - route_list_add_vpn_gateway(c->c1.route_list, c->c2= .es, dhcp_router); - } - } - } - else if (is_ipv6(TUNNEL_TYPE(c->c1.tuntap), &ipbuf)) + /* possibly alter the TCP MSS */ + if (flags & PIP_MSSFIX) { - /* possibly alter the TCP MSS */ - if (flags & PIP_MSSFIX) - { - mss_fixup_ipv6(&ipbuf, c->c2.frame.mss_fix); - } - if (!(flags & PIP_OUTGOING) && (flags - &(PIPV6_IMCP_NOHOST_CLIENT= | PIPV6_IMCP_NOHOST_SERVER))) - { - ipv6_send_icmp_unreachable(c, buf, - (bool)(flags & PIPV6_IMCP_N= OHOST_CLIENT)); - /* Drop the IPv6 packet */ - buf->len =3D 0; - } - + mss_fixup_ipv4(&ipbuf, c->c2.frame.mss_fix); } + + /* possibly do NAT on packet */ + if ((flags & PIPV4_CLIENT_NAT) && c->options.client_nat) + { + const int direction =3D (flags & PIP_OUTGOING) ? CN_INCOMI= NG : CN_OUTGOING; + client_nat_transform(c->options.client_nat, &ipbuf, direct= ion); + } + /* possibly extract a DHCP router message */ + if (flags & PIPV4_EXTRACT_DHCP_ROUTER) + { + const in_addr_t dhcp_router =3D dhcp_extract_router_msg(&i= pbuf); + if (dhcp_router) + { + route_list_add_vpn_gateway(c->c1.route_list, c->c2.es,= dhcp_router); + } + } + } + else if (is_ipv6(TUNNEL_TYPE(c->c1.tuntap), &ipbuf)) + { + /* possibly alter the TCP MSS */ + if (flags & PIP_MSSFIX) + { + mss_fixup_ipv6(&ipbuf, c->c2.frame.mss_fix); + } + if (!(flags & PIP_OUTGOING) && (flags + &(PIPV6_ICMP_NOHOST_CLIENT | P= IPV6_ICMP_NOHOST_SERVER))) + { + ipv6_send_icmp_unreachable(c, buf, + (bool)(flags & PIPV6_ICMP_NOHOS= T_CLIENT)); + /* Drop the IPv6 packet */ + buf->len =3D 0; + } + } } } diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index e19115e..bc00ba5 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -297,8 +297,9 @@ #define PIP_OUTGOING (1<<2) #define PIPV4_EXTRACT_DHCP_ROUTER (1<<3) #define PIPV4_CLIENT_NAT (1<<4) -#define PIPV6_IMCP_NOHOST_CLIENT (1<<5) -#define PIPV6_IMCP_NOHOST_SERVER (1<<6) +#define PIPV6_ICMP_NOHOST_CLIENT (1<<5) +#define PIPV6_ICMP_NOHOST_SERVER (1<<6) + void process_ip_header(struct context *c, unsigned int flags, struct buffe= r *buf); diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 4344126..712456c 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -3645,7 +3645,7 @@ if (mbuf_extract_item(ms, &item)) /* cleartext IP packet */ { - unsigned int pip_flags =3D PIPV4_PASSTOS | PIPV6_IMCP_NOHOST_SERVE= R; + unsigned int pip_flags =3D PIPV4_PASSTOS | PIPV6_ICMP_NOHOST_SERVE= R; set_prefix(item.instance); item.instance->context.c2.buf =3D item.buffer->buf; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/525?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I4b5e8357d872c920efdb64632e9bce72cebee202 Gerrit-Change-Number: 525 Gerrit-PatchSet: 6 Gerrit-Owner: its_Giaan Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --F+97Bx7bgPc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #6 to the change originally cr= eated by its_Giaan.

View Change

The following approvals got outdated= and were removed: Code-Review+2 by flichtenheld, Code-Review+2 by plaisthos

Minor fix to proc=
ess_ip_header

Removed if-guard checking if any feature is
enabled= before performing per-feature check.
It doesn't save us much but in= stead introduces
uneeded complexity.

While at it, fixed a typo IM= CP -> ICMP for defined
PIPV6_ICMP_NOHOST_CLIENT and PIPV6_ICMP_NOHOST= _SERVER
macros.

Fixes: Trac https://community.openvpn.net/openvpn= /ticket/269
Change-Id: I4b5e8357d872c920efdb64632e9bce72cebee202
Sign= ed-off-by: Gianmarco De Gregori <gianmarco@...2726...>
Acked-by: A= rne Schwabe <arne-openvpn@...1227...>
Acked-by: Frank Lichtenheld = <frank@...2641...>
Message-Id: <20240307124616.16358-1-gert@...493...= 1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1659...= forge.net/msg28345.html
Signed-off-by: Gert Doering <gert@...1296...&= gt;
---
M src/openvpn/forward.c
M src/openvpn/forward.h
M src/o= penvpn/multi.c
3 files changed, 49 insertions(+), 61 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/25/525/6
diff --git a/src/openvpn/forward.c b/src/openvpn/forward.cindex 0443ca0..556c465 100644
--- a/src/openvpn/forw= ard.c
+++ b/src/openvpn/forward.c
@@ -1460,= 7 +1460,7 @@
* us to examine the IP header (IPv4 = or IPv6).
*/
unsigned in= t flags =3D PIPV4_PASSTOS | PIP_MSSFIX | PIPV4_CLIENT_NAT
- | PIPV6_IM= CP_NOHOST_CLIENT;
+ = | PIPV6_ICMP_NOHOST_CLIENT;
= process_ip_header(c, flags, &c->c2.buf);

#ifdef PACKET_TRUNCATION_CHECK
@@ -1644,73 +16= 44,60 @@
}
if (!c->options.blo= ck_ipv6)
{
- flags &=3D ~(PIPV6_IMCP_NOHOST_CLIENT | PIPV6_IMCP_NO= HOST_SERVER);
+ = flags &=3D ~(PIPV6_ICMP_NOHOST_CLIENT | PIPV6_ICMP_NOHOST_SERVER);
}

if (buf->len= > 0)
{
- /*
- = * The --passtos and --mssfix options require
- * us to examine the IPv4 header.
- */
<= span style=3D"color: hsl(0, 100%, 40%);">-

- if (flags & (PIP_MSSFIX
-#if PASSTOS_CAPABILITY
- | PIPV4_PASSTOS
-#endif
- | PIPV4_CLIENT_NAT=
- = ))
+ struct bu= ffer ipbuf =3D *buf;
= + if (is_ipv4(TUNNEL_TYPE(c->c1.tuntap), &ipbuf))
<= span> {

- = struct buffer ipbuf =3D *buf;
- if (is_ipv4(TUNNEL_TYPE(c->c1.tuntap), &ip= buf))
- {
#if PASSTOS_CAPABILITY
- /* extract TOS from IP header */
= - if (flags & = PIPV4_PASSTOS)
- = {
- = link_socket_extract_tos(c->c2.link_socket, &ipbuf);<= br>- }
<= span style=3D"color: hsl(120, 100%, 40%);">+ /* extract TOS from= IP header */

+ = if (flags & PIPV4_PASSTOS)
+ {
+ link_socket_extract_tos(c->c2.link_socket, &a= mp;ipbuf);
+ = }
#endif

- /* possibly alter the TCP MSS */
- if (fla= gs & PIP_MSSFIX)
- = {
- = mss_fixup_ipv4(&ipbuf, c->c2.frame.mss_fix);- }
-

- /* possibly do NAT on packet */<= br>- if ((flags &a= mp; PIPV4_CLIENT_NAT) && c->options.client_nat)
- {
- const int direction = =3D (flags & PIP_OUTGOING) ? CN_INCOMING : CN_OUTGOING;
- client_nat_transf= orm(c->options.client_nat, &ipbuf, direction);

- }
- /* possibly extract a DHCP rout= er message */
- = if (flags & PIPV4_EXTRACT_DHCP_ROUTER)
- {
- const in_addr_t dhcp_router = =3D dhcp_extract_router_msg(&ipbuf);
- if (dhcp_router)
- {
- route_list_add_vp= n_gateway(c->c1.route_list, c->c2.es, dhcp_router);
- }
- }
- }
- else if (is_ipv6(TUNNEL_TYPE(c->c1.t= untap), &ipbuf))
= + /* possibly alter the TCP MSS */
+ if (flags & PIP_MSSFIX) {
-= /* possibly alter the TCP MSS */
- if (flags & PIP_MSSFIX)
- {- mss_fixup_= ipv6(&ipbuf, c->c2.frame.mss_fix);
- }
- if (!(flags & PIP_OUTGOING) && = (flags
- = &(PIPV6_IMCP_NOHOST_CLIENT | PIPV6_IMC= P_NOHOST_SERVER)))
- = {
- = ipv6_send_icmp_unreachable(c, buf,
- (b= ool)(flags & PIPV6_IMCP_NOHOST_CLIENT));
- /* Drop the IPv6 packet */
- buf->= ;len =3D 0;
- = }
-
+ mss_fixup_ipv4(&a= mp;ipbuf, c->c2.frame.mss_fix);

}+
+ /* possibly do NAT on packet */
+ if ((flags &= amp; PIPV4_CLIENT_NAT) && c->options.client_nat)
+ {

+ const int direction =3D (= flags & PIP_OUTGOING) ? CN_INCOMING : CN_OUTGOING;
+ client_nat_transform(c-&= gt;options.client_nat, &ipbuf, direction);
+ }
+ /* possibly extract a DHCP router message = */
+ if (f= lags & PIPV4_EXTRACT_DHCP_ROUTER)
+ {
+ const in_addr_t dhcp_router =3D dhcp_extract_ro= uter_msg(&ipbuf);
+ if (dhcp_router)
+ {
+ route_list_add_vpn_gateway(c->c1.route_= list, c->c2.es, dhcp_router);
+ }
+ }
+ }
+ = else if (is_ipv6(TUNNEL_TYPE(c->c1.tuntap), &ipbuf))
+ {

+ /* possibly alter the TCP MSS= */
+ if (= flags & PIP_MSSFIX)
+ {
+ = mss_fixup_ipv6(&ipbuf, c->c2.frame.mss_fix);+ }
+ if (!(flags & PIP_O= UTGOING) && (flags

+ &(PIPV6_ICMP_NOHOST_= CLIENT | PIPV6_ICMP_NOHOST_SERVER)))
+ {
+ ipv6_send_icmp_unreachable(c, buf,
+ = (bool)(flags & PIPV6_ICMP_NOHOST_CLIENT));
+ /* Drop the IPv6 packe= t */
+ = buf->len =3D 0;
+= }
+
}
}
}
<= span>diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h

<= span>index e19115e..bc00ba5 100644
--- a/src/openvpn/forwar= d.h
+++ b/src/openvpn/forward.h
@@ -297,8 += 297,9 @@
#define PIP_OUTGOING (1<<= ;2)
#define PIPV4_EXTRACT_DHCP_ROUTER (1<<3)
#define PIPV4_CLIENT_NAT (1<<4)=
-#define PIPV6_IMCP_NOHOST_CL= IENT (1<<5)
+#define PIPV6_ICMP_NOHOST_CLIENT = (1<<5)
+#defin= e PIPV6_ICMP_NOHOST_SERVER (1<<6)
+

void process= _ip_header(struct context *c, unsigned int flags, struct buffer *buf);

diff --git a/src/openvpn/multi.c b/src/openvp= n/multi.c
index 4344126..712456c 100644
---= a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
= @@ -3645,7 +3645,7 @@

if (mbuf= _extract_item(ms, &item)) /* cleartext IP packet */
= {
- unsigned i= nt pip_flags =3D PIPV4_PASSTOS | PIPV6_IMCP_NOHOST_SERVER;
+ unsigned int pip_flags =3D P= IPV4_PASSTOS | PIPV6_ICMP_NOHOST_SERVER;

= set_prefix(item.instance);
item.instance-= >context.c2.buf =3D item.buffer->buf;

To view, visit change 525. To unsubscribe, or for help writing mail filters= , visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4b5e8357d872c920efdb64632e9= bce72cebee202
Gerrit-Change-Number: 525
Gerrit-PatchSet: 6
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: ordex <a@...2181...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--F+97Bx7bgPc=--