[dpdk-dev] [PATCH v2 4/6] net/pcap: add libpcap wrappers

Nick Connolly nick.connolly at mayadata.io
Thu Feb 25 21:31:27 CET 2021


> Your comment made me revise Windows EAL networking shims. Surprisingly, if
> changed to expose Windows networking headers (specifically, <ws2tcpip.h>) with
> some additions (but no hacks), they create no issues to any existing code.
>
> The only workaround remaining is `#undef s_addr` in <rte_ether.h>.
>
> So maybe this commit can be dropped, if Windows EAL networking headers be
> reworked in the following way:
>
> 	#if defined min
> 	#define USER_EXPLICITLY_WANTS_WINDOWS_H
> 	#endif
>
> 	#include <ws2tcpip.h>
>
> 	/* hide definitions that break portable code,
> 	 * e.g. it had to be done once already for i40e
> 	 */
> 	#ifndef USER_EXPLICITLY_WANTS_WINDOWS_H
> 	#undef min, max, ...
> 	#endif
>
> 	#define what's missing from Windows headers, e.g. IPPROTO_SCTP
>
> + Windows maintainers, Nick Connolly, and Jie Zhou to discuss.
In my opinion, there are long term maintenance issues either way round.

Wrapping the system headers hides the details and keeps the code 'clean',
but has to work with multiple compiler environments and versions of the
headers - not always straightforward.  Wrapping libpcap involves code
changes that need to be maintained.

For SPDK, changing the code wasn't really an option, so I had to go with
wrapping the headers. It's worked out ok so far. To make it a bit cleaner
I turned off as much as possible from Windows.h with #define NO*.
Supporting both clang and MinGW caused a few issues (e.g. MinGW has
mswsock.h), but they are solvable.

./inc/sys/socket.h and ./inc/wpdk/windows.h in https://github.com/wpdp/wpdk
show an example of what might need wrapping in the general case.

Regards,
Nick


More information about the dev mailing list