From: "ordex (Code Review)" Date: Tue, 29 Oct 2024 13:44:07 +0000 References: Reply-To: a@...2181..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="PpC9mlSwuRo="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: sitnl: replace NLMSG_TAIL macro with nlmsg_tail() function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --PpC9mlSwuRo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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/+/788?usp=3Demail to review the following change. Change subject: sitnl: replace NLMSG_TAIL macro with nlmsg_tail() function ...................................................................... sitnl: replace NLMSG_TAIL macro with nlmsg_tail() function The NLMSG_TAIL macro never had any reason to exist, because libnl already provides a function doing exactly the same: nlmsg_tail(). Moreover, this macro was found to confuse gcc when compiling with -O3, which would result in subsequent warnings like: networking_sitnl.c:143:9: warning: writing 4 bytes into a region of size 0 = [-Wstringop-overflow=3D] 143 | memcpy(RTA_DATA(rta), data, alen); | ^ networking_sitnl.c:101:21: note: at offset [72, 88] into destination object= =E2=80=98n=E2=80=99 of size 16 101 | struct nlmsghdr n; | ^ (Above warnings are critical on Fedora 40 as they are turned into errors) Delete the macro, replace it with nlmsg_tail() and get rid of the warnings. Change-Id: I9306a590a10a7d5cba32abe06d269494fec41ba6 Signed-off-by: Antonio Quartulli --- M src/openvpn/networking_sitnl.c 1 file changed, 4 insertions(+), 6 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/88/788/1 diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c index f53f5ee..8eeab72 100644 --- a/src/openvpn/networking_sitnl.c +++ b/src/openvpn/networking_sitnl.c @@ -40,6 +40,7 @@ #include #include #include +#include #define SNDBUF_SIZE (1024 * 2) #define RCVBUF_SIZE (1024 * 4) @@ -52,19 +53,16 @@ } \ } -#define NLMSG_TAIL(nmsg) \ - ((struct rtattr *)(((uint8_t *)(nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len= ))) - #define SITNL_NEST(_msg, _max_size, _attr) \ ({ \ - struct rtattr *_nest =3D NLMSG_TAIL(_msg); \ + struct rtattr *_nest =3D nlmsg_tail(_msg); \ SITNL_ADDATTR(_msg, _max_size, _attr, NULL, 0); \ _nest; \ }) #define SITNL_NEST_END(_msg, _nest) \ { \ - _nest->rta_len =3D (void *)NLMSG_TAIL(_msg) - (void *)_nest; \ + _nest->rta_len =3D (void *)nlmsg_tail(_msg) - (void *)_nest; \ } /** @@ -130,7 +128,7 @@ return -EMSGSIZE; } - rta =3D NLMSG_TAIL(n); + rta =3D nlmsg_tail(n); rta->rta_type =3D type; rta->rta_len =3D len; --=20 To view, visit http://gerrit.openvpn.net/c/openvpn/+/788?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: I9306a590a10a7d5cba32abe06d269494fec41ba6 Gerrit-Change-Number: 788 Gerrit-PatchSet: 1 Gerrit-Owner: ordex Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --PpC9mlSwuRo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

ordex would like plaisthos and flichtenheld to review t= his change.

Vi= ew Change

sitnl: replace NLMSG_TAIL macro with nlmsg_tail() function
The NLMSG_TAIL macro never had any reason to exist, because libnl
a= lready provides a function doing exactly the same: nlmsg_tail().

Mor= eover, this macro was found to confuse gcc when compiling with -O3,
whic= h would result in subsequent warnings like:

networking_sitnl.c:143:9= : warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=3D]=
143 | memcpy(RTA_DATA(rta), data, alen);
| ^=
networking_sitnl.c:101:21: note: at offset [72, 88] into destination ob= ject =E2=80=98n=E2=80=99 of size 16
101 | struct nlmsghdr n;
= | ^

(Above warnings are critical on Fedora 4= 0 as they are turned into errors)

Delete the macro, replace it with = nlmsg_tail() and get rid of the
warnings.

Change-Id: I9306a590a10= a7d5cba32abe06d269494fec41ba6
Signed-off-by: Antonio Quartulli <anton= io@...2726...>
---
M src/openvpn/networking_sitnl.c
1 file chan= ged, 4 insertions(+), 6 deletions(-)

git pull ssh://gerrit.openvp=
n.net:29418/openvpn refs/changes/88/788/1
diff --git a/src/openvpn/=
networking_sitnl.c b/src/openvpn/networking_sitnl.c
index f= 53f5ee..8eeab72 100644
--- a/src/openvpn/networking_sitnl.c=
+++ b/src/openvpn/networking_sitnl.c
@@ -4= 0,6 +40,7 @@
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/rtne= tlink.h>
+#include= <netlink/msg.h>

#define SNDBUF_SI= ZE (1024 * 2)
#define RCVBUF_SIZE (1024 * 4)
@@ -52,19 +53,16 @@
} = \
}
=
-#define NLMSG_TAIL(nm= sg) \
- ((struct rta= ttr *)(((uint8_t *)(nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
= -
#define SITNL_= NEST(_msg, _max_size, _attr) \
({ = \
- struct rtattr *_nest =3D NLMSG_TAIL(_msg); = \
+ struc= t rtattr *_nest =3D nlmsg_tail(_msg); \
SIT= NL_ADDATTR(_msg, _max_size, _attr, NULL, 0); \
_ne= st; \
})

#define SITNL_NEST_END(_msg, _nest) = \
{ = \
- _nest->rta_len =3D (void *)NLMSG_TAIL(_msg) - (v= oid *)_nest; \
+ = _nest->rta_len =3D (void *)nlmsg_tail(_msg) - (void *)_nest; \
}

/**
@= @ -130,7 +128,7 @@
return -EMSGSIZE;
}


- rta =3D NLMSG_TAIL(n);
+ rta =3D nlmsg_tail(n);
rta->rta_ty= pe =3D type;
rta->rta_len =3D len;
=

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9306a590a10a7d5cba32abe06d2= 69494fec41ba6
Gerrit-Change-Number: 788
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <a@...2181...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--PpC9mlSwuRo=--