Split libopenvswitch into two libraries:

 - libopenvswitchutils: containers, utilities, I/O, threading,
   logging, and OVSDB client modules.
 - libopenvswitch: datapath, OpenFlow, netdev, dpif, flow,
   conntrack, and related modules.

Programs that do not need datapath functionality now link only
libopenvswitchutils, reducing their dependency footprint:
ovsdb-server, ovsdb-client, ovsdb-tool, ovs-appctl, vtep-ctl,
test-lib.

When OVS is built with static DPDK (--with-dpdk=static), these
programs no longer pull in DPDK code at all.  Stripped binary
sizes (x86_64, DPDK 25.11.2):

  Binary          Before    After    Saved
  ovs-appctl     4,434 KB   355 KB    -92%
  ovsdb-server   4,742 KB   775 KB    -84%
  ovsdb-client   4,729 KB   758 KB    -84%
  ovsdb-tool     4,709 KB   738 KB    -84%
  vtep-ctl       4,752 KB   856 KB    -82%
  test-lib       4,430 KB   351 KB    -92%

Binaries that still need libopenvswitch (ovs-vsctl, ovs-dpctl,
ovs-ofctl, ovs-vswitchd) are unaffected by this change.  Further
reducing their DPDK dependency requires decoupling dp-packet from
netdev-dpdk, which is separate follow-up work.

Changes since v7:
  - Fixed the FreeBSD build: netaddr.c now includes <sys/socket.h>
    for AF_INET and AF_INET6 (Ilya Maximets).
  - Restored the IPV6_SCAN_FMT usage example comment lost in the
    move to netaddr.h, and corrected the number of moved functions
    in the commit message to 36 (Ilya Maximets).
  - smap, socket-util and the stream modules now include netaddr.h
    instead of packets.h, and stream.c no longer includes flow.h,
    so the utils library no longer depends on packets.h at the
    source level (Ilya Maximets).
  - Moved the NEWS entry to the Post-v4.0.0 section and rebased on
    current main (Ilya Maximets).
  - libopenvswitch now links libopenvswitchutils instead of both
    libraries absorbing the libovsutil convenience library, so only
    one copy of the utils code (constructors, RCU thread, signal
    handlers, global state) is ever loaded in a process
    (Ilya Maximets).  On the hash and CFLAGS concern from v6: both
    libraries are built in the same tree with the same CFLAGS, and
    libopenvswitch depends on the versioned SONAME of
    libopenvswitchutils, so mismatched versions cannot be loaded
    together.  The cost is that programs linking libopenvswitch
    list libopenvswitchutils too, which is required for shared
    builds.  External users such as OVN, which link
    libopenvswitch.la, are fine in the default static build; with
    an --enable-shared OVS they need to add libopenvswitchutils.
    libopenvswitch.pc now has Requires.private: libopenvswitchutils
    and keeps only @LIBS@ in Libs.private.

Changes since v6:
  - Split the series into two patches per Ilya's review:
    1/2 extracts address functions from packets.[ch] into a new
    netaddr.[ch] module (Ilya Maximets).
    2/2 introduces the library split using netaddr.[ch] as part
    of libopenvswitchutils.
  - Replaced the static inline wrappers (ip_parse, ipv6_parse,
    ipv6_string_mapped) in packets.h with proper function
    definitions in netaddr.c, resolving the logical isolation
    concern (Ilya Maximets).
  - Both libraries now absorb a shared noinst convenience library
    (libovsutil) so header-only code (hashes, atomics) is compiled
    once with identical CFLAGS, addressing the hash divergence
    concern (Ilya Maximets).
  - Programs that link libopenvswitch no longer need to also list
    libopenvswitchutils in LDADD, since libopenvswitch already
    contains all utils symbols through the convenience library
    (Ilya Maximets).
  - Moved unaligned.h to the utils library where it belongs
    (Ilya Maximets).
  - Updated USDT probe scripts to also search libopenvswitchutils
    for struct definitions (Ilya Maximets).
  - Fixed pre-existing checkpatch warnings and errors in code
    moved to netaddr.[ch] (cast spacing, operator spacing,
    line length, for-loop whitespace).

Changes since v5:
  - test-lib: removed unused vconn.h include and switched LDADD
    from libopenvswitch to libopenvswitchutils only (David Marchand).
  - Added static DPDK size measurements to the commit message.

Changes since v4:
  - Squashed into a single patch.
  - Dropped net-proto rename per Ilya's review: keep packets.c/h
    as-is, no new net-proto.c/h files.
  - Dropped pop_mpls and other function moves to dp-packet per
    Ilya's review.
  - Inlined ip_parse(), ipv6_parse(), ipv6_string_mapped() in
    packets.h to resolve cross-library dependency (trivial
    wrappers around inet_pton/inet_ntop).
  - Fixed shared library builds: link libopenvswitchutils.la
    explicitly in every executable that also links libopenvswitch.la
    (utilities, vswitchd, tests, oss-fuzz), so the directly
    referenced utils symbols resolve under --enable-shared.
  - Fixed debian Python extension: link libopenvswitchutils
    instead of libopenvswitch.
  - Fixed sparse checker: include ordering in packets.h.
  - Kept the generated vswitch-idl in libopenvswitch (datapath and
    schema consumers); only dirs and ovsdb-server-idl moved to the
    libopenvswitchutils sources.
  - Dropped the redundant @LIBS@ from libopenvswitch.pc.in; it is
    chained in through Requires.private: libopenvswitchutils.

Changes since v3:
  - Rebased on current main (resolved conflict in NEWS).

Changes since v2:
  - Fixed checkpatch warnings and errors (cast spacing, operator spacing,
    line length, for-loop whitespace, commit subject length).
  - Separated the public header rename into its own commit for clarity.
  - Moved dirs.h from libopenvswitch to libopenvswitchutils sources
    to be consistent with dirs.c.

Changes since v1 (Aaron Conole <[email protected]>):
  - Reordered: flow_tnl_equal removal moved to patch 1 as suggested by
    David Marchand (independent cleanup, easier to review first)
  - Fixed: flow_tnl_src()/flow_tnl_dst() moved from lib/dp-packet.c to
    lib/flow.c as requested by David Marchand and Ilya Maximets
  - Fixed: missing packet_set_ipv6_flow_label and packet_set_ipv6_tc
    renames added to NEWS as pointed out by David Marchand

Timothy Redaelli (2):
  lib: Extract address functions from packets into netaddr module.
  libs: Introduce libopenvswitchutils for common routines.

 NEWS                                         |   7 +
 configure.ac                                 |   2 +
 debian/rules                                 |   4 +-
 lib/.gitignore                               |   1 +
 lib/automake.mk                              | 371 +++++-----
 lib/libopenvswitch.pc.in                     |   3 +-
 lib/libopenvswitchutils.pc.in                |  11 +
 lib/libopenvswitchutils.sym.in               |   4 +
 lib/netaddr.c                                | 668 +++++++++++++++++++
 lib/netaddr.h                                | 429 ++++++++++++
 lib/packets.c                                | 641 ------------------
 lib/packets.h                                | 390 +----------
 lib/smap.c                                   |   2 +-
 lib/socket-util.c                            |   2 +-
 lib/stream-ssl.c                             |   2 +-
 lib/stream-tcp.c                             |   2 +-
 lib/stream-unix.c                            |   2 +-
 lib/stream.c                                 |   3 +-
 ovsdb/automake.mk                            |   6 +-
 python/setup.py.template                     |   2 +-
 tests/automake.mk                            |   8 +-
 tests/oss-fuzz/automake.mk                   |  12 +-
 tests/test-lib.c                             |   1 -
 utilities/automake.mk                        |  13 +-
 utilities/usdt-scripts/flow_reval_monitor.py |   1 +
 utilities/usdt-scripts/reval_monitor.py      |   4 +-
 vswitchd/automake.mk                         |   3 +-
 vtep/automake.mk                             |   2 +-
 28 files changed, 1353 insertions(+), 1243 deletions(-)
 create mode 100644 lib/libopenvswitchutils.pc.in
 create mode 100644 lib/libopenvswitchutils.sym.in
 create mode 100644 lib/netaddr.c
 create mode 100644 lib/netaddr.h

-- 
2.56.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to