mbox series

[v3,0/3] net/pcap: build on Windows

Message ID 20210324005008.24705-1-dmitry.kozliuk@gmail.com (mailing list archive)
Headers
Series net/pcap: build on Windows |

Message

Dmitry Kozlyuk March 24, 2021, 12:50 a.m. UTC
  NOTE: dependency patches are requirements, CI may fail.

Most modern and actively maintained distribution of libpcap for Windows
is Npcap [1]. It currently doesn't provide a pkg-config file [2].
By default it is installed to C:\Program Files\Npcap and can be located
using standard environment variables [3]:

    $env:C_INCLUDE_PATH += ";C:\Program Files\Npcap"
    $env:LIBRARY_PATH += ";C:\Program Files\Npcap\Lib\x64"     # MinGW
    $env:LINK += ' /LIBPATH:"C:\Program Files\Npcap\Lib\x64"'  # Clang

The following libpcap.pc also works if placed in PKG_CONFIG_PATH:

    prefix="C:/Program Files/Npcap"
    Name: libpcap
    Version: 1.10
    Description: Platform-independent network traffic capture library
    Cflags: -I${prefix}/Include
    Libs: -L${prefix}/Lib/x64 -lwpcap

Example of collecting packets from an interface to a file:

    .\build\examples\dpdk-skeleton.exe `
        --vdev "eth_pcap0,iface=\Device\NPF_{DDD48985-A77C-4FC9-AF48-61E547C8797E}" `
        --vdev "eth_pcap1,tx_pcap=capture.pcap"

Interface name can be obtained as follows, with Wireshark installed:

    & "C:\Program Files\Wireshark\tshark.exe" -D

Implementation in "pcap_osdep_windows.c" does some guesswork to convert
between variants of an interface name. Microsoft experts and interested
users, please take a look and/or give it a try in your environment.

[1]: https://nmap.org/npcap
[2]: https://github.com/nmap/npcap/issues/299
[3]: https://mesonbuild.com/Reference-manual.html#compiler-object

Depends-on: series-15801 ("eal/windows: do not expose POSIX symbols")
Depends-on: patch-89639 ("[v2,3/3] meson: remove unnecessary explicit link to libpcap")

v3:
    * Use environment and pkg-config to locate libpcap (Bruce).
    * Use C11 timespec_get() instead of EAL wrapper.
    * Drop libpcap wrappers in net/pcap (Ferruh).

Dmitry Kozlyuk (3):
  eal/windows: add timespec_get shim for MinGW
  net/pcap: move OS-dependent code to separate files
  net/pcap: build on Windows

 config/meson.build                            |   3 +-
 doc/guides/rel_notes/release_21_05.rst        |   4 +
 drivers/net/pcap/meson.build                  |  16 +--
 .../pcap/{rte_eth_pcap.c => pcap_ethdev.c}    | 109 +++-------------
 drivers/net/pcap/pcap_osdep.h                 |  18 +++
 drivers/net/pcap/pcap_osdep_freebsd.c         |  59 +++++++++
 drivers/net/pcap/pcap_osdep_linux.c           |  42 +++++++
 drivers/net/pcap/pcap_osdep_windows.c         | 118 ++++++++++++++++++
 .../windows/include/rte_os_internal.h         |  32 +++++
 9 files changed, 303 insertions(+), 98 deletions(-)
 rename drivers/net/pcap/{rte_eth_pcap.c => pcap_ethdev.c} (95%)
 create mode 100644 drivers/net/pcap/pcap_osdep.h
 create mode 100644 drivers/net/pcap/pcap_osdep_freebsd.c
 create mode 100644 drivers/net/pcap/pcap_osdep_linux.c
 create mode 100644 drivers/net/pcap/pcap_osdep_windows.c
  

Comments

Ferruh Yigit April 9, 2021, 10:51 a.m. UTC | #1
On 3/24/2021 12:50 AM, Dmitry Kozlyuk wrote:
> NOTE: dependency patches are requirements, CI may fail.
> 
> Most modern and actively maintained distribution of libpcap for Windows
> is Npcap [1]. It currently doesn't provide a pkg-config file [2].
> By default it is installed to C:\Program Files\Npcap and can be located
> using standard environment variables [3]:
> 
>      $env:C_INCLUDE_PATH += ";C:\Program Files\Npcap"
>      $env:LIBRARY_PATH += ";C:\Program Files\Npcap\Lib\x64"     # MinGW
>      $env:LINK += ' /LIBPATH:"C:\Program Files\Npcap\Lib\x64"'  # Clang
> 
> The following libpcap.pc also works if placed in PKG_CONFIG_PATH:
> 
>      prefix="C:/Program Files/Npcap"
>      Name: libpcap
>      Version: 1.10
>      Description: Platform-independent network traffic capture library
>      Cflags: -I${prefix}/Include
>      Libs: -L${prefix}/Lib/x64 -lwpcap
> 
> Example of collecting packets from an interface to a file:
> 
>      .\build\examples\dpdk-skeleton.exe `
>          --vdev "eth_pcap0,iface=\Device\NPF_{DDD48985-A77C-4FC9-AF48-61E547C8797E}" `
>          --vdev "eth_pcap1,tx_pcap=capture.pcap"
> 
> Interface name can be obtained as follows, with Wireshark installed:
> 
>      & "C:\Program Files\Wireshark\tshark.exe" -D
> 
> Implementation in "pcap_osdep_windows.c" does some guesswork to convert
> between variants of an interface name. Microsoft experts and interested
> users, please take a look and/or give it a try in your environment.
> 
> [1]: https://nmap.org/npcap
> [2]: https://github.com/nmap/npcap/issues/299
> [3]: https://mesonbuild.com/Reference-manual.html#compiler-object
> 
> Depends-on: series-15801 ("eal/windows: do not expose POSIX symbols")
> Depends-on: patch-89639 ("[v2,3/3] meson: remove unnecessary explicit link to libpcap")
> 

Hi Dmitry,

What is the status of the dependent patches, are they merged?

> v3:
>      * Use environment and pkg-config to locate libpcap (Bruce).
>      * Use C11 timespec_get() instead of EAL wrapper.
>      * Drop libpcap wrappers in net/pcap (Ferruh).
> 
> Dmitry Kozlyuk (3):
>    eal/windows: add timespec_get shim for MinGW
>    net/pcap: move OS-dependent code to separate files
>    net/pcap: build on Windows
> 
>   config/meson.build                            |   3 +-
>   doc/guides/rel_notes/release_21_05.rst        |   4 +
>   drivers/net/pcap/meson.build                  |  16 +--
>   .../pcap/{rte_eth_pcap.c => pcap_ethdev.c}    | 109 +++-------------
>   drivers/net/pcap/pcap_osdep.h                 |  18 +++
>   drivers/net/pcap/pcap_osdep_freebsd.c         |  59 +++++++++
>   drivers/net/pcap/pcap_osdep_linux.c           |  42 +++++++
>   drivers/net/pcap/pcap_osdep_windows.c         | 118 ++++++++++++++++++
>   .../windows/include/rte_os_internal.h         |  32 +++++
>   9 files changed, 303 insertions(+), 98 deletions(-)
>   rename drivers/net/pcap/{rte_eth_pcap.c => pcap_ethdev.c} (95%)
>   create mode 100644 drivers/net/pcap/pcap_osdep.h
>   create mode 100644 drivers/net/pcap/pcap_osdep_freebsd.c
>   create mode 100644 drivers/net/pcap/pcap_osdep_linux.c
>   create mode 100644 drivers/net/pcap/pcap_osdep_windows.c
>
  
Dmitry Kozlyuk April 9, 2021, 11:03 a.m. UTC | #2
2021-04-09 11:51 (UTC+0100), Ferruh Yigit:
> On 3/24/2021 12:50 AM, Dmitry Kozlyuk wrote:
[...]
> > Depends-on: series-15801 ("eal/windows: do not expose POSIX symbols")
> > Depends-on: patch-89639 ("[v2,3/3] meson: remove unnecessary explicit link to libpcap")
> >   
> 
> Hi Dmitry,
> 
> What is the status of the dependent patches, are they merged?

Hi Ferruh,

Not yet, but reviews are progressing.
series-15801 has some acks and no pending changes, probably close to merge.
AFAIK, Thomas is now reviewing patch-89639 to improve its description.
This series will need a v4 for trivial rebase and to trigger a CI run.
  
Ferruh Yigit April 9, 2021, 11:24 a.m. UTC | #3
On 4/9/2021 12:03 PM, Dmitry Kozlyuk wrote:
> 2021-04-09 11:51 (UTC+0100), Ferruh Yigit:
>> On 3/24/2021 12:50 AM, Dmitry Kozlyuk wrote:
> [...]
>>> Depends-on: series-15801 ("eal/windows: do not expose POSIX symbols")
>>> Depends-on: patch-89639 ("[v2,3/3] meson: remove unnecessary explicit link to libpcap")
>>>    
>>
>> Hi Dmitry,
>>
>> What is the status of the dependent patches, are they merged?
> 
> Hi Ferruh,
> 
> Not yet, but reviews are progressing.
> series-15801 has some acks and no pending changes, probably close to merge.
> AFAIK, Thomas is now reviewing patch-89639 to improve its description.
> This series will need a v4 for trivial rebase and to trigger a CI run.
> 

Thanks Dmitry, cc'ed Thomas.