From: "cron2 (Code Review)" Date: Wed, 8 Oct 2025 16:12:26 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., max@...2606... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="UzXwBjg7+WQ="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: proto: Clean up conversion warnings related to checksum macros List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos , MaxF Cc: openvpn-devel --UzXwBjg7+WQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#5) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1164?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by MaxF Change subject: proto: Clean up conversion warnings related to checksum mac= ros ...................................................................... proto: Clean up conversion warnings related to checksum macros These should not change any behavior, they mostly clarify the used types and silence warnings, since these casts are deliberate. Change-Id: Ica721a51b00d5314125bcaf5a586e718c5982aef Signed-off-by: Frank Lichtenheld Acked-by: MaxF Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1164 Message-Id: <20250926111726.153603-1-frank@...2641...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33= 218.html Signed-off-by: Gert Doering --- M src/openvpn/clinat.c M src/openvpn/mss.c M src/openvpn/proto.h 3 files changed, 36 insertions(+), 51 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/64/1164/5 diff --git a/src/openvpn/clinat.c b/src/openvpn/clinat.c index b49d4bb..7751a47 100644 --- a/src/openvpn/clinat.c +++ b/src/openvpn/clinat.c @@ -185,11 +185,7 @@ const int direction) { struct ip_tcp_udp_hdr *h =3D (struct ip_tcp_udp_hdr *)BPTR(ipbuf); - int i; - uint32_t addr, *addr_ptr; - const uint32_t *from, *to; - int accumulate =3D 0; - unsigned int amask; + int32_t accumulate =3D 0; unsigned int alog =3D 0; if (check_debug_level(D_CLIENT_NAT)) @@ -197,8 +193,11 @@ print_pkt(&h->ip, "BEFORE", direction, D_CLIENT_NAT); } - for (i =3D 0; i < list->n; ++i) + for (int i =3D 0; i < list->n; ++i) { + uint32_t addr, *addr_ptr; + const uint32_t *from, *to; + unsigned int amask; const struct client_nat_entry *e =3D &list->entries[i]; /* current= NAT rule */ if (e->type ^ direction) { diff --git a/src/openvpn/mss.c b/src/openvpn/mss.c index e7111a8..10d61d1 100644 --- a/src/openvpn/mss.c +++ b/src/openvpn/mss.c @@ -130,11 +130,6 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /* * change TCP MSS option in SYN/SYN-ACK packets, if present * this is generic for IPv4 and IPv6, as the TCP header is the same @@ -143,11 +138,8 @@ void mss_fixup_dowork(struct buffer *buf, uint16_t maxmss) { - int hlen, olen, optlen; + int olen, optlen; uint8_t *opt; - uint16_t mssval; - int accumulate; - struct openvpn_tcphdr *tc; if (BLEN(buf) < (int)sizeof(struct openvpn_tcphdr)) { @@ -155,8 +147,8 @@ } verify_align_4(buf); - tc =3D (struct openvpn_tcphdr *)BPTR(buf); - hlen =3D OPENVPN_TCPH_GET_DOFF(tc->doff_res); + struct openvpn_tcphdr *tc =3D (struct openvpn_tcphdr *)BPTR(buf); + int hlen =3D OPENVPN_TCPH_GET_DOFF(tc->doff_res); /* Invalid header length or header without options. */ if (hlen <=3D (int)sizeof(struct openvpn_tcphdr) || hlen > BLEN(buf)) @@ -171,43 +163,37 @@ { break; } - else if (*opt =3D=3D OPENVPN_TCPOPT_NOP) + if (*opt =3D=3D OPENVPN_TCPOPT_NOP) { optlen =3D 1; + continue; } - else + + optlen =3D *(opt + 1); + if (optlen <=3D 0 || optlen > olen) { - optlen =3D *(opt + 1); - if (optlen <=3D 0 || optlen > olen) + break; + } + if (*opt =3D=3D OPENVPN_TCPOPT_MAXSEG) + { + if (optlen !=3D OPENVPN_TCPOLEN_MAXSEG) { - break; + continue; } - if (*opt =3D=3D OPENVPN_TCPOPT_MAXSEG) + uint16_t mssval =3D (uint16_t)(opt[2] << 8) + opt[3]; + if (mssval > maxmss) { - if (optlen !=3D OPENVPN_TCPOLEN_MAXSEG) - { - continue; - } - mssval =3D opt[2] << 8; - mssval +=3D opt[3]; - if (mssval > maxmss) - { - dmsg(D_MSS, "MSS: %" PRIu16 " -> %" PRIu16, mssval, ma= xmss); - accumulate =3D htons(mssval); - opt[2] =3D (uint8_t)((maxmss >> 8) & 0xff); - opt[3] =3D (uint8_t)(maxmss & 0xff); - accumulate -=3D htons(maxmss); - ADJUST_CHECKSUM(accumulate, tc->check); - } + dmsg(D_MSS, "MSS: %" PRIu16 " -> %" PRIu16, mssval, maxmss= ); + opt[2] =3D (uint8_t)((maxmss >> 8) & 0xff); + opt[3] =3D (uint8_t)(maxmss & 0xff); + int32_t accumulate =3D htons(mssval); + accumulate -=3D htons(maxmss); + ADJUST_CHECKSUM(accumulate, tc->check); } } } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - static inline size_t adjust_payload_max_cbc(const struct key_type *kt, size_t target) { diff --git a/src/openvpn/proto.h b/src/openvpn/proto.h index 62157fa..94952bd 100644 --- a/src/openvpn/proto.h +++ b/src/openvpn/proto.h @@ -214,7 +214,7 @@ */ #define ADJUST_CHECKSUM(acc, cksum) \ { \ - int _acc =3D acc; \ + int32_t _acc =3D acc; \ _acc +=3D (cksum); \ if (_acc < 0) \ { \ @@ -231,16 +231,16 @@ } \ } -#define ADD_CHECKSUM_32(acc, u32) \ - { \ - acc +=3D (u32) & 0xffff; \ - acc +=3D (u32) >> 16; \ +#define ADD_CHECKSUM_32(acc, u32) \ + { \ + acc +=3D (int32_t)((u32) & 0xffff); \ + acc +=3D (int32_t)((u32) >> 16); \ } -#define SUB_CHECKSUM_32(acc, u32) \ - { \ - acc -=3D (u32) & 0xffff; \ - acc -=3D (u32) >> 16; \ +#define SUB_CHECKSUM_32(acc, u32) \ + { \ + acc -=3D (int32_t)((u32) & 0xffff); \ + acc -=3D (int32_t)((u32) >> 16); \ } /* -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1164?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ica721a51b00d5314125bcaf5a586e718c5982aef Gerrit-Change-Number: 1164 Gerrit-PatchSet: 5 Gerrit-Owner: flichtenheld Gerrit-Reviewer: MaxF Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --UzXwBjg7+WQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #5 to the change originally created by flichtenhel= d.

View Change

The following approvals got outdated and were remove= d: Code-Review+2 by MaxF

proto: Clean up conversion warnings =
related to checksum macros

These should not change any behavior, the= y mostly clarify
the used types and silence warnings, since these casts = are
deliberate.

Change-Id: Ica721a51b00d5314125bcaf5a586e718c5982= aef
Signed-off-by: Frank Lichtenheld <frank@...2641...>
Acked-b= y: MaxF <max@...2606...>
Gerrit URL: https://gerrit.openvpn.net/c/= openvpn/+/1164
Message-Id: <20250926111726.153603-1-frank@...2641...&= gt;
URL: https://www.mail-archive.com/openvpn-devel@...475...= t/msg33218.html
Signed-off-by: Gert Doering <gert@...1296...>
-= --
M src/openvpn/clinat.c
M src/openvpn/mss.c
M src/openvpn/proto.= h
3 files changed, 36 insertions(+), 51 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/64/116=
4/5
diff --git a/src/openvpn/clinat.c b/src/openvpn/clinat.c=

index b49d4bb..7751a47 100644
--- a/src/openvpn/c= linat.c
+++ b/src/openvpn/clinat.c
@@ -185,= 11 +185,7 @@
const int direction)
{
struct ip_tcp_udp_hdr *h =3D (struct i= p_tcp_udp_hdr *)BPTR(ipbuf);
- int i;
- = uint32_t addr, *addr_ptr;
- const uint32_t *from, *to;
- int accumulate =3D 0;
- unsigned int amask;
+ int32_t accumulate =3D 0;
uns= igned int alog =3D 0;

if (check_debu= g_level(D_CLIENT_NAT))
@@ -197,8 +193,11 @@
print_pkt(&h->ip, "BEFORE", direction, D_CLIENT_= NAT);

}

- for (i =3D 0; i < list->n; ++i)+ for (int i =3D 0; i <= list->n; ++i)
{
+ uint32_t addr, *addr_ptr;
+ const uint32_t *from, *to;
+ unsigned int amas= k;
const struct client_nat_entry *e =3D &list-= >entries[i]; /* current NAT rule */
if (e->t= ype ^ direction)
{
diff --git a/sr= c/openvpn/mss.c b/src/openvpn/mss.c
index e7111a8..10d61d1 = 100644
--- a/src/openvpn/mss.c
+++ b/src/op= envpn/mss.c
@@ -130,11 +130,6 @@
}
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored &quo= t;-Wconversion"

-#= endif
-
/*

* change TCP MSS option in SYN/SYN-ACK packets, if p= resent
* this is generic for IPv4 and IPv6, as the TCP he= ader is the same
@@ -143,11 +138,8 @@
void=
mss_fixup_dowork(struct buffer *buf, uint16_t maxmss)
{
- in= t hlen, olen, optlen;
+ int olen, optlen;
uint8_t *opt;
- uint16_t mssval;
- int accumulate;
- struct openvpn_tcphdr *tc;
=
if (BLEN(buf) < (int)sizeof(struct openvpn_= tcphdr))
{
@@ -155,8 +147,8 @@<= br> }

verify_align_4(buf);=
- tc =3D (struct op= envpn_tcphdr *)BPTR(buf);
- hlen =3D OPENVPN_TCPH_GET_DOFF(tc->doff_res);
+ struct openvpn_tcphdr *tc =3D (str= uct openvpn_tcphdr *)BPTR(buf);
+ int hlen =3D OPENVPN_TCPH_GET_DOFF(tc->doff_res);=

/* Invalid header length or header without= options. */
if (hlen <=3D (int)sizeof(struct openv= pn_tcphdr) || hlen > BLEN(buf))
@@ -171,43 +163,37 @@
{
break;
}

- e= lse if (*opt =3D=3D OPENVPN_TCPOPT_NOP)
+ if (*opt =3D=3D OPENVPN_TCPOPT_NOP)
<= span> {

optlen =3D 1;
+ continue;
}
- e= lse
+
+ optlen =3D *(opt + 1);

+ if (optlen <= =3D 0 || optlen > olen)
{
- optlen =3D *(opt + 1);- if (optlen <=3D= 0 || optlen > olen)
+ break;
+ = if (*opt =3D=3D OPENVPN_TCPOPT_MAXSEG)
+ {
+ if (optlen !=3D OPENVPN_TCPOLEN_MAXSEG)
{
- = break;
+ = continue;
}
- if (*opt =3D=3D OPENVPN_TCPOP= T_MAXSEG)
+ = uint16_t mssval =3D (uint16_t)(opt[2] << 8) + opt[3];
+ if (mssval > maxms= s)
{
- if (optlen !=3D OPENVPN_TCPOLEN_MAXSEG)<= br>- {
<= span style=3D"color: hsl(0, 100%, 40%);">- continue;

- }<= br>- mssval =3D op= t[2] << 8;
- = mssval +=3D opt[3];
- if (mssval > maxmss)
- {
- dmsg(D_MSS, "MSS: %" P= RIu16 " -> %" PRIu16, mssval, maxmss);
- accumulate =3D htons(ms= sval);
- = opt[2] =3D (uint8_t)((maxmss >> 8) & 0xff);
- opt[3] =3D (uint8_= t)(maxmss & 0xff);
= - accumulate -=3D htons(maxmss);
- ADJUST_CHECKSUM(accumul= ate, tc->check);
- = }
+ = dmsg(D_MSS, "MSS: %" PRIu16 " -> %" PRIu= 16, mssval, maxmss);
= + opt[2] =3D (uint8_t)((maxmss >> 8) & 0xff);
+ opt[3] = =3D (uint8_t)(maxmss & 0xff);
+ int32_t accumulate =3D htons(mssval);<= br>+ accumulate = -=3D htons(maxmss);
+= ADJUST_CHECKSUM(accumulate, tc->check);
= }
}
}
= }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
static inline size_t
ad= just_payload_max_cbc(const struct key_type *kt, size_t target)
{

diff --git a/src/openvpn/proto.h b/src/openvpn/proto= .h
index 62157fa..94952bd 100644
--- a/src/= openvpn/proto.h
+++ b/src/openvpn/proto.h
@= @ -214,7 +214,7 @@
*/
#define ADJUST_CHE= CKSUM(acc, cksum) \
{ = \
- int _acc =3D acc; \
+ int32_t _acc =3D acc; = \
_acc +=3D (cksum); = \
if (_acc < 0) = \
{ = \
@@ -231,16 +231,16 @@
= } \
}=

-#define AD= D_CHECKSUM_32(acc, u32) \
- { \
- acc +=3D (u32) & 0xffff; \
- acc +=3D (u32) >> 16; = \
+#define ADD_C= HECKSUM_32(acc, u32) \
+ { \
+ acc +=3D (int32_t)((u32) & 0= xffff); \
+ ac= c +=3D (int32_t)((u32) >> 16); \
}
=
-#define SUB_CH= ECKSUM_32(acc, u32) \
-= { \
- acc -=3D (u32) & 0xffff; \
- acc -=3D (u32) >> 16; = \
+#define SUB_CHECK= SUM_32(acc, u32) \
+ { \
+ acc -=3D (int32_t)((u32) & 0xfff= f); \
+ acc -= =3D (int32_t)((u32) >> 16); \
}

/*

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ica721a51b00d5314125bcaf5a58= 6e718c5982aef
Gerrit-Change-Number: 1164
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: MaxF <max@...2606...> <= /div>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --UzXwBjg7+WQ=--