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. Links libopenvswitchutils.
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): Binary Before After Saved ovs-appctl 3,939 KB 346 KB -91% ovsdb-server 4,255 KB 766 KB -82% ovsdb-client 4,234 KB 750 KB -82% ovsdb-tool 4,218 KB 729 KB -83% vtep-ctl 4,273 KB 847 KB -80% test-lib 3,935 KB 342 KB -91% 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. To break a circular dependency between the two libraries, ip_parse(), ipv6_parse(), and ipv6_string_mapped() are made static inline in packets.h. These are trivial wrappers around inet_pton()/inet_ntop() with no side effects or state. Signed-off-by: Timothy Redaelli <[email protected]> --- 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 NEWS | 6 + configure.ac | 2 + debian/rules | 4 +- lib/.gitignore | 1 + lib/automake.mk | 362 +++++++++++++++++---------------- lib/libopenvswitch.pc.in | 2 +- lib/libopenvswitchutils.pc.in | 11 + lib/libopenvswitchutils.sym.in | 4 + lib/packets.c | 31 --- lib/packets.h | 33 ++- 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 +- vswitchd/automake.mk | 3 +- vtep/automake.mk | 2 +- 18 files changed, 269 insertions(+), 234 deletions(-) create mode 100644 lib/libopenvswitchutils.pc.in create mode 100644 lib/libopenvswitchutils.sym.in diff --git a/NEWS b/NEWS index c9331321c..d2d39149b 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,11 @@ Post-v3.7.0 -------------------- + - The libopenvswitch library has been split into libopenvswitch (datapath, + OpenFlow, netdev) and libopenvswitchutils (utilities, containers, I/O, + OVSDB client). Programs that do not need the datapath functionality + (e.g. ovsdb-server, ovsdb-client) now link only libopenvswitchutils. + The ip_parse(), ipv6_parse() and ipv6_string_mapped() functions are now + static inline in packets.h and are no longer exported by libopenvswitch. - Userspace datapath: * ARP/ND lookups for native tunnel are now rate limited. The holdout timer can be configured with 'tnl/neigh/retrans_time'. diff --git a/configure.ac b/configure.ac index 1b3dba501..0bb70450b 100644 --- a/configure.ac +++ b/configure.ac @@ -149,6 +149,7 @@ AC_CONFIG_FILES([ ofproto/libofproto.sym lib/libsflow.sym lib/libopenvswitch.sym + lib/libopenvswitchutils.sym vtep/libvtep.sym]) OVS_ENABLE_OPTION([-Wall]) @@ -204,6 +205,7 @@ AC_SUBST([OVS_LDFLAGS]) AC_CONFIG_FILES(Makefile) AC_CONFIG_FILES(tests/atlocal) AC_CONFIG_FILES(lib/libopenvswitch.pc) +AC_CONFIG_FILES(lib/libopenvswitchutils.pc) AC_CONFIG_FILES(lib/libsflow.pc) AC_CONFIG_FILES(ofproto/libofproto.pc) AC_CONFIG_FILES(ovsdb/libovsdb.pc) diff --git a/debian/rules b/debian/rules index f36d45593..8941f67ba 100755 --- a/debian/rules +++ b/debian/rules @@ -88,8 +88,8 @@ pybuild = \ export PKG_CONFIG_SYSTEM_INCLUDE_PATH=/; \ export PKG_CONFIG_SYSTEM_LIBRARY_PATH=/; \ enable_shared=no \ - extra_cflags="`pkg-config --cflags libopenvswitch`" \ - extra_libs="-Wl,-Bstatic -lopenvswitch -Wl,-Bdynamic `pkg-config --libs --static libopenvswitch`" \ + extra_cflags="`pkg-config --cflags libopenvswitchutils`" \ + extra_libs="-Wl,-Bstatic -lopenvswitchutils -Wl,-Bdynamic `pkg-config --libs --static libopenvswitchutils`" \ pybuild override_dh_auto_build: diff --git a/lib/.gitignore b/lib/.gitignore index ec9bdb092..31575a202 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -19,4 +19,5 @@ /vswitch-idl.h /vswitch-idl.ovsidl /libopenvswitch.pc +/libopenvswitchutils.pc /libsflow.pc diff --git a/lib/automake.mk b/lib/automake.mk index 2dfca79da..a97df9255 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -5,36 +5,26 @@ # notice and this notice are preserved. This file is offered as-is, # without warranty of any kind. -lib_LTLIBRARIES += lib/libopenvswitch.la +lib_LTLIBRARIES += lib/libopenvswitchutils.la -lib_libopenvswitch_la_LIBADD = $(SSL_LIBS) -lib_libopenvswitch_la_LIBADD += $(CAPNG_LDADD) +lib_libopenvswitchutils_la_LIBADD = $(SSL_LIBS) +lib_libopenvswitchutils_la_LIBADD += $(CAPNG_LDADD) -lib_libopenvswitch_la_LDFLAGS = \ +lib_libopenvswitchutils_la_LDFLAGS = \ $(OVS_LTINFO) \ - -Wl,--version-script=$(top_builddir)/lib/libopenvswitch.sym \ + -Wl,--version-script=$(top_builddir)/lib/libopenvswitchutils.sym \ $(AM_LDFLAGS) -# Build core vswitch libraries as before -lib_libopenvswitch_la_SOURCES = \ +lib_libopenvswitchutils_la_SOURCES = \ lib/aes128.c \ lib/aes128.h \ lib/async-append.h \ lib/backtrace.c \ lib/backtrace.h \ - lib/bfd.c \ - lib/bfd.h \ lib/bitmap.h \ - lib/bundle.c \ - lib/bundle.h \ lib/byte-order.h \ lib/byteq.c \ lib/byteq.h \ - lib/cfm.c \ - lib/cfm.h \ - lib/classifier.c \ - lib/classifier.h \ - lib/classifier-private.h \ lib/ccmap.c \ lib/ccmap.h \ lib/cmap.c \ @@ -44,16 +34,6 @@ lib_libopenvswitch_la_SOURCES = \ lib/command-line.c \ lib/command-line.h \ lib/compiler.h \ - lib/connectivity.c \ - lib/connectivity.h \ - lib/conntrack-icmp.c \ - lib/conntrack-private.h \ - lib/conntrack-tcp.c \ - lib/conntrack-tp.c \ - lib/conntrack-tp.h \ - lib/conntrack-other.c \ - lib/conntrack.c \ - lib/conntrack.h \ lib/cooperative-multitasking.c \ lib/cooperative-multitasking.h \ lib/cooperative-multitasking-private.h \ @@ -63,42 +43,13 @@ lib_libopenvswitch_la_SOURCES = \ lib/crc32c.h \ lib/csum.c \ lib/csum.h \ - lib/ct-dpif.c \ - lib/ct-dpif.h \ lib/daemon.c \ lib/daemon.h \ lib/daemon-private.h \ lib/db-ctl-base.c \ lib/db-ctl-base.h \ - lib/dhcp.h \ - lib/dummy.c \ - lib/dummy.h \ lib/dhparams.h \ lib/dirs.h \ - lib/dpctl.c \ - lib/dpctl.h \ - lib/dp-packet.h \ - lib/dp-packet.c \ - lib/dp-packet-gso.c \ - lib/dp-packet-gso.h \ - lib/dpdk.h \ - lib/dpif-netdev-dfc.c \ - lib/dpif-netdev-dfc.h \ - lib/dpif-netdev-dpcls.c \ - lib/dpif-netdev-dpcls.h \ - lib/dpif-netdev-flow.h \ - lib/dpif-netdev-perf.c \ - lib/dpif-netdev-perf.h \ - lib/dpif-netdev-thread.h \ - lib/dpif-netdev.c \ - lib/dpif-netdev.h \ - lib/dpif-offload.c \ - lib/dpif-offload.h \ - lib/dpif-offload-dummy.c \ - lib/dpif-offload-provider.h \ - lib/dpif-provider.h \ - lib/dpif.c \ - lib/dpif.h \ lib/heap.c \ lib/heap.h \ lib/dynamic-string.c \ @@ -108,8 +59,6 @@ lib_libopenvswitch_la_SOURCES = \ lib/fat-rwlock.h \ lib/fatal-signal.c \ lib/fatal-signal.h \ - lib/flow.c \ - lib/flow.h \ lib/guarded-list.c \ lib/guarded-list.h \ lib/hash.c \ @@ -124,85 +73,23 @@ lib_libopenvswitch_la_SOURCES = \ lib/id-fpool.h \ lib/id-pool.c \ lib/id-pool.h \ - lib/if-notifier-manual.c \ - lib/if-notifier.h \ - lib/ipf.c \ - lib/ipf.h \ lib/jhash.c \ lib/jhash.h \ lib/json.c \ lib/json.h \ lib/jsonrpc.c \ lib/jsonrpc.h \ - lib/lacp.c \ - lib/lacp.h \ lib/latch.h \ - lib/learn.c \ - lib/learn.h \ - lib/learning-switch.c \ - lib/learning-switch.h \ lib/lockfile.c \ lib/lockfile.h \ - lib/mac-learning.c \ - lib/mac-learning.h \ - lib/match.c \ - lib/mcast-snooping.c \ - lib/mcast-snooping.h \ lib/memory.c \ lib/memory.h \ - lib/meta-flow.c \ lib/mov-avg.h \ lib/mpsc-queue.c \ lib/mpsc-queue.h \ - lib/multipath.c \ - lib/multipath.h \ lib/namemap.c \ - lib/netdev-dpdk.h \ - lib/netdev-dummy.c \ - lib/netdev-provider.h \ - lib/netdev-vport.c \ - lib/netdev-vport.h \ - lib/netdev-vport-private.h \ - lib/netdev.c \ - lib/netdev.h \ - lib/netflow.h \ - lib/netlink.c \ - lib/netlink.h \ - lib/netnsid.c \ - lib/netnsid.h \ - lib/nx-match.c \ - lib/nx-match.h \ lib/object-collection.c \ lib/object-collection.h \ - lib/odp-execute.c \ - lib/odp-execute.h \ - lib/odp-util.c \ - lib/odp-util.h \ - lib/ofp-actions.c \ - lib/ofp-bundle.c \ - lib/ofp-connection.c \ - lib/ofp-ct.c \ - lib/ofp-ed-props.c \ - lib/ofp-errors.c \ - lib/ofp-flow.c \ - lib/ofp-group.c \ - lib/ofp-ipfix.c \ - lib/ofp-match.c \ - lib/ofp-meter.c \ - lib/ofp-monitor.c \ - lib/ofp-msgs.c \ - lib/ofp-packet.c \ - lib/ofp-parse.c \ - lib/ofp-port.c \ - lib/ofp-print.c \ - lib/ofp-prop.c \ - lib/ofp-protocol.c \ - lib/ofp-queue.c \ - lib/ofp-switch.c \ - lib/ofp-table.c \ - lib/ofp-util.c \ - lib/ofp-version-opt.h \ - lib/ofp-version-opt.c \ lib/ofpbuf.c \ lib/ovs-atomic-c++.h \ lib/ovs-atomic-c11.h \ @@ -216,16 +103,12 @@ lib_libopenvswitch_la_SOURCES = \ lib/ovs-atomic-pthreads.h \ lib/ovs-atomic-x86_64.h \ lib/ovs-atomic.h \ - lib/ovs-lldp.c \ - lib/ovs-lldp.h \ lib/ovs-numa.c \ lib/ovs-numa.h \ lib/ovs-rcu.c \ lib/ovs-rcu.h \ lib/ovs-replay.c \ lib/ovs-replay.h \ - lib/ovs-router.h \ - lib/ovs-router.c \ lib/ovs-thread.c \ lib/ovs-thread.h \ lib/ovsdb-cs.c \ @@ -249,12 +132,6 @@ lib_libopenvswitch_la_SOURCES = \ lib/ovsdb-session.h \ lib/ovsdb-types.c \ lib/ovsdb-types.h \ - lib/ox-stat.c \ - lib/ox-stat.h \ - lib/packets.c \ - lib/packets.h \ - lib/pcap-file.c \ - lib/pcap-file.h \ lib/perf-counter.h \ lib/perf-counter.c \ lib/stopwatch.h \ @@ -266,15 +143,9 @@ lib_libopenvswitch_la_SOURCES = \ lib/pvector.h \ lib/random.c \ lib/random.h \ - lib/rconn.c \ lib/rculist.h \ lib/reconnect.c \ lib/reconnect.h \ - lib/rstp.c \ - lib/rstp.h \ - lib/rstp-common.h \ - lib/rstp-state-machines.c \ - lib/rstp-state-machines.h \ lib/sat-math.h \ lib/seq.c \ lib/seq.h \ @@ -293,8 +164,6 @@ lib_libopenvswitch_la_SOURCES = \ lib/sort.h \ lib/sset.c \ lib/sset.h \ - lib/stp.c \ - lib/stp.h \ lib/stream-fd.c \ lib/stream-fd.h \ lib/stream-provider.h \ @@ -319,22 +188,11 @@ lib_libopenvswitch_la_SOURCES = \ lib/timer.h \ lib/timeval.c \ lib/timeval.h \ - lib/tnl-neigh-cache.c \ - lib/tnl-neigh-cache.h \ - lib/tnl-ports.c \ - lib/tnl-ports.h \ - lib/netdev-native-tnl.c \ - lib/netdev-native-tnl.h \ lib/token-bucket.c \ - lib/tun-metadata.c \ - lib/tun-metadata.h \ - lib/unaligned.h \ lib/unicode.c \ lib/unicode.h \ lib/unixctl.c \ lib/unixctl.h \ - lib/userspace-tso.c \ - lib/userspace-tso.h \ lib/util.c \ lib/util.h \ lib/uuid.c \ @@ -342,24 +200,9 @@ lib_libopenvswitch_la_SOURCES = \ lib/uuidset.c \ lib/uuidset.h \ lib/valgrind.h \ - lib/vconn-provider.h \ - lib/vconn-stream.c \ - lib/vconn.c \ - lib/versions.h \ - lib/vl-mff-map.h \ - lib/vlan-bitmap.c \ - lib/vlan-bitmap.h \ - lib/vlog.c \ - lib/lldp/aa-structs.h \ - lib/lldp/lldp.c \ - lib/lldp/lldp-const.h \ - lib/lldp/lldp-tlv.h \ - lib/lldp/lldpd.c \ - lib/lldp/lldpd.h \ - lib/lldp/lldpd-structs.c \ - lib/lldp/lldpd-structs.h + lib/vlog.c -lib_libopenvswitch_la_SOURCES += \ +lib_libopenvswitchutils_la_SOURCES += \ lib/daemon-unix.c \ lib/latch-unix.c \ lib/signals.c \ @@ -370,14 +213,184 @@ lib_libopenvswitch_la_SOURCES += \ EXTRA_DIST += \ lib/string.h.in -nodist_lib_libopenvswitch_la_SOURCES = \ +nodist_lib_libopenvswitchutils_la_SOURCES = \ lib/dirs.c \ lib/ovsdb-server-idl.c \ - lib/ovsdb-server-idl.h \ + lib/ovsdb-server-idl.h +CLEANFILES += $(nodist_lib_libopenvswitchutils_la_SOURCES) + +lib_LTLIBRARIES += lib/libopenvswitch.la + +lib_libopenvswitch_la_LIBADD = lib/libopenvswitchutils.la + +nodist_lib_libopenvswitch_la_SOURCES = \ lib/vswitch-idl.c \ lib/vswitch-idl.h CLEANFILES += $(nodist_lib_libopenvswitch_la_SOURCES) +lib_libopenvswitch_la_LDFLAGS = \ + $(OVS_LTINFO) \ + -Wl,--version-script=$(top_builddir)/lib/libopenvswitch.sym \ + $(AM_LDFLAGS) + +lib_libopenvswitch_la_SOURCES = \ + lib/bfd.c \ + lib/bfd.h \ + lib/bundle.c \ + lib/bundle.h \ + lib/cfm.c \ + lib/cfm.h \ + lib/classifier.c \ + lib/classifier.h \ + lib/classifier-private.h \ + lib/connectivity.c \ + lib/connectivity.h \ + lib/conntrack-icmp.c \ + lib/conntrack-private.h \ + lib/conntrack-tcp.c \ + lib/conntrack-tp.c \ + lib/conntrack-tp.h \ + lib/conntrack-other.c \ + lib/conntrack.c \ + lib/conntrack.h \ + lib/ct-dpif.c \ + lib/ct-dpif.h \ + lib/dhcp.h \ + lib/dummy.c \ + lib/dummy.h \ + lib/dpctl.c \ + lib/dpctl.h \ + lib/dp-packet.h \ + lib/dp-packet.c \ + lib/dp-packet-gso.c \ + lib/dp-packet-gso.h \ + lib/dpdk.h \ + lib/dpif-netdev-dfc.c \ + lib/dpif-netdev-dfc.h \ + lib/dpif-netdev-dpcls.c \ + lib/dpif-netdev-dpcls.h \ + lib/dpif-netdev-flow.h \ + lib/dpif-netdev-perf.c \ + lib/dpif-netdev-perf.h \ + lib/dpif-netdev-thread.h \ + lib/dpif-netdev.c \ + lib/dpif-netdev.h \ + lib/dpif-offload.c \ + lib/dpif-offload.h \ + lib/dpif-offload-dummy.c \ + lib/dpif-offload-provider.h \ + lib/dpif-provider.h \ + lib/dpif.c \ + lib/dpif.h \ + lib/flow.c \ + lib/flow.h \ + lib/if-notifier-manual.c \ + lib/if-notifier.h \ + lib/ipf.c \ + lib/ipf.h \ + lib/lacp.c \ + lib/lacp.h \ + lib/learn.c \ + lib/learn.h \ + lib/learning-switch.c \ + lib/learning-switch.h \ + lib/mac-learning.c \ + lib/mac-learning.h \ + lib/match.c \ + lib/mcast-snooping.c \ + lib/mcast-snooping.h \ + lib/meta-flow.c \ + lib/multipath.c \ + lib/multipath.h \ + lib/netdev-dpdk.h \ + lib/netdev-dummy.c \ + lib/netdev-provider.h \ + lib/netdev-vport.c \ + lib/netdev-vport.h \ + lib/netdev-vport-private.h \ + lib/netdev.c \ + lib/netdev.h \ + lib/netflow.h \ + lib/netlink.c \ + lib/netlink.h \ + lib/netnsid.c \ + lib/netnsid.h \ + lib/nx-match.c \ + lib/nx-match.h \ + lib/odp-execute.c \ + lib/odp-execute.h \ + lib/odp-util.c \ + lib/odp-util.h \ + lib/ofp-actions.c \ + lib/ofp-bundle.c \ + lib/ofp-connection.c \ + lib/ofp-ct.c \ + lib/ofp-ed-props.c \ + lib/ofp-errors.c \ + lib/ofp-flow.c \ + lib/ofp-group.c \ + lib/ofp-ipfix.c \ + lib/ofp-match.c \ + lib/ofp-meter.c \ + lib/ofp-monitor.c \ + lib/ofp-msgs.c \ + lib/ofp-packet.c \ + lib/ofp-parse.c \ + lib/ofp-port.c \ + lib/ofp-print.c \ + lib/ofp-prop.c \ + lib/ofp-protocol.c \ + lib/ofp-queue.c \ + lib/ofp-switch.c \ + lib/ofp-table.c \ + lib/ofp-util.c \ + lib/ofp-version-opt.h \ + lib/ofp-version-opt.c \ + lib/ovs-lldp.c \ + lib/ovs-lldp.h \ + lib/ovs-router.h \ + lib/ovs-router.c \ + lib/ox-stat.c \ + lib/ox-stat.h \ + lib/packets.c \ + lib/packets.h \ + lib/pcap-file.c \ + lib/pcap-file.h \ + lib/rconn.c \ + lib/rstp.c \ + lib/rstp.h \ + lib/rstp-common.h \ + lib/rstp-state-machines.c \ + lib/rstp-state-machines.h \ + lib/stp.c \ + lib/stp.h \ + lib/tnl-neigh-cache.c \ + lib/tnl-neigh-cache.h \ + lib/tnl-ports.c \ + lib/tnl-ports.h \ + lib/netdev-native-tnl.c \ + lib/netdev-native-tnl.h \ + lib/tun-metadata.c \ + lib/tun-metadata.h \ + lib/unaligned.h \ + lib/userspace-tso.c \ + lib/userspace-tso.h \ + lib/vconn-provider.h \ + lib/vconn-stream.c \ + lib/vconn.c \ + lib/versions.h \ + lib/vl-mff-map.h \ + lib/vlan-bitmap.c \ + lib/vlan-bitmap.h \ + lib/lldp/aa-structs.h \ + lib/lldp/lldp.c \ + lib/lldp/lldp-const.h \ + lib/lldp/lldp-tlv.h \ + lib/lldp/lldpd.c \ + lib/lldp/lldpd.h \ + lib/lldp/lldpd-structs.c \ + lib/lldp/lldpd-structs.h + lib_LTLIBRARIES += lib/libsflow.la lib_libsflow_la_LDFLAGS = \ $(OVS_LTINFO) \ @@ -448,9 +461,9 @@ lib_libopenvswitch_la_SOURCES += \ endif if HAVE_POSIX_AIO -lib_libopenvswitch_la_SOURCES += lib/async-append-aio.c +lib_libopenvswitchutils_la_SOURCES += lib/async-append-aio.c else -lib_libopenvswitch_la_SOURCES += lib/async-append-null.c +lib_libopenvswitchutils_la_SOURCES += lib/async-append-null.c endif if HAVE_IF_DL @@ -464,7 +477,7 @@ endif .PHONY: generate-dhparams-c if HAVE_OPENSSL -lib_libopenvswitch_la_SOURCES += lib/stream-ssl.c lib/dhparams.c +lib_libopenvswitchutils_la_SOURCES += lib/stream-ssl.c lib/dhparams.c # Manually regenerates lib/dhparams.c. Not normally necessary since # lib/dhparams.c is part of the repository and doesn't normally need @@ -474,18 +487,19 @@ generate-dhparams-c: build-aux/generate-dhparams-c > lib/dhparams.c.tmp && \ mv lib/dhparams.c.tmp lib/dhparams.c else -lib_libopenvswitch_la_SOURCES += lib/stream-nossl.c +lib_libopenvswitchutils_la_SOURCES += lib/stream-nossl.c endif -lib_libopenvswitch_la_SOURCES += lib/dns-resolve.h +lib_libopenvswitchutils_la_SOURCES += lib/dns-resolve.h if HAVE_UNBOUND -lib_libopenvswitch_la_SOURCES += lib/dns-resolve.c +lib_libopenvswitchutils_la_SOURCES += lib/dns-resolve.c else -lib_libopenvswitch_la_SOURCES += lib/dns-resolve-stub.c +lib_libopenvswitchutils_la_SOURCES += lib/dns-resolve-stub.c endif pkgconfig_DATA += \ lib/libopenvswitch.pc \ + lib/libopenvswitchutils.pc \ lib/libsflow.pc EXTRA_DIST += \ diff --git a/lib/libopenvswitch.pc.in b/lib/libopenvswitch.pc.in index a5f4d3947..f63a97bc3 100644 --- a/lib/libopenvswitch.pc.in +++ b/lib/libopenvswitch.pc.in @@ -7,5 +7,5 @@ Name: libopenvswitch Description: Open vSwitch library Version: @VERSION@ Libs: -L${libdir} -lopenvswitch -Libs.private: @LIBS@ @SSL_LIBS@ @CAPNG_LDADD@ +Requires.private: libopenvswitchutils Cflags: -I${includedir} diff --git a/lib/libopenvswitchutils.pc.in b/lib/libopenvswitchutils.pc.in new file mode 100644 index 000000000..d8915d4eb --- /dev/null +++ b/lib/libopenvswitchutils.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libopenvswitchutils +Description: Open vSwitch common library +Version: @VERSION@ +Libs: -L${libdir} -lopenvswitchutils +Libs.private: @LIBS@ @SSL_LIBS@ @CAPNG_LDADD@ +Cflags: -I${includedir} diff --git a/lib/libopenvswitchutils.sym.in b/lib/libopenvswitchutils.sym.in new file mode 100644 index 000000000..f7e32afba --- /dev/null +++ b/lib/libopenvswitchutils.sym.in @@ -0,0 +1,4 @@ +libopenvswitchutils_@LT_CURRENT@ { +global: + *; +}; diff --git a/lib/packets.c b/lib/packets.c index 80c41e4b6..9663610cb 100644 --- a/lib/packets.c +++ b/lib/packets.c @@ -691,14 +691,6 @@ ip_format_masked(ovs_be32 ip, ovs_be32 mask, struct ds *s) } } -/* Parses string 's', which must be an IP address. Stores the IP address into - * '*ip'. Returns true if successful, otherwise false. */ -bool -ip_parse(const char *s, ovs_be32 *ip) -{ - return inet_pton(AF_INET, s, ip) == 1; -} - /* Parses string 's', which must be an IP address with a port number * with ":" as a separator (e.g.: 192.168.1.2:80). * Stores the IP address into '*ip' and port number to '*port'. @@ -801,14 +793,6 @@ ip_parse_cidr(const char *s, ovs_be32 *ip, unsigned int *plen) return error; } -/* Parses string 's', which must be an IPv6 address. Stores the IPv6 address - * into '*ip'. Returns true if successful, otherwise false. */ -bool -ipv6_parse(const char *s, struct in6_addr *ip) -{ - return inet_pton(AF_INET6, s, ip) == 1; -} - /* Parses string 's', which must be an IPv6 address with an optional netmask or * CIDR prefix length. Stores the IPv6 address into '*ip' and the netmask into * '*mask' (if 's' does not contain a netmask, all-one-bits is assumed), and @@ -952,21 +936,6 @@ ipv6_format_masked(const struct in6_addr *addr, const struct in6_addr *mask, } } -/* Stores the string representation of the IPv6 address 'addr' into the - * character array 'addr_str', which must be at least INET6_ADDRSTRLEN - * bytes long. If addr is IPv4-mapped, store an IPv4 dotted-decimal string. */ -const char * -ipv6_string_mapped(char *addr_str, const struct in6_addr *addr) -{ - ovs_be32 ip; - ip = in6_addr_get_mapped_ipv4(addr); - if (ip) { - return inet_ntop(AF_INET, &ip, addr_str, INET6_ADDRSTRLEN); - } else { - return inet_ntop(AF_INET6, addr, addr_str, INET6_ADDRSTRLEN); - } -} - #ifdef s6_addr32 #define s6_addrX s6_addr32 #define IPV6_FOR_EACH(VAR) for (int VAR = 0; VAR < 4; VAR++) diff --git a/lib/packets.h b/lib/packets.h index ea0bda840..1f693ebc8 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -19,6 +19,8 @@ #include <inttypes.h> #include <sys/types.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include <stdint.h> #include <string.h> #include "compiler.h" @@ -677,7 +679,13 @@ ip_is_local_multicast(ovs_be32 ip) } int ip_count_cidr_bits(ovs_be32 netmask); void ip_format_masked(ovs_be32 ip, ovs_be32 mask, struct ds *); -bool ip_parse(const char *s, ovs_be32 *ip); +/* Parses string 's', which must be an IP address. Stores the IP address into + * '*ip'. Returns true if successful, otherwise false. */ +static inline bool +ip_parse(const char *s, ovs_be32 *ip) +{ + return inet_pton(AF_INET, s, ip) == 1; +} char *ip_parse_port(const char *s, ovs_be32 *ip, ovs_be16 *port) OVS_WARN_UNUSED_RESULT; char *ip_parse_masked(const char *s, ovs_be32 *ip, ovs_be32 *mask) @@ -1604,7 +1612,20 @@ void ipv6_format_addr_bracket(const struct in6_addr *addr, struct ds *, void ipv6_format_mapped(const struct in6_addr *addr, struct ds *); void ipv6_format_masked(const struct in6_addr *addr, const struct in6_addr *mask, struct ds *); -const char * ipv6_string_mapped(char *addr_str, const struct in6_addr *addr); +/* Stores the string representation of the IPv6 address 'addr' into the + * character array 'addr_str', which must be at least INET6_ADDRSTRLEN + * bytes long. If addr is IPv4-mapped, store an IPv4 dotted-decimal string. */ +static inline const char * +ipv6_string_mapped(char *addr_str, const struct in6_addr *addr) +{ + ovs_be32 ip; + ip = in6_addr_get_mapped_ipv4(addr); + if (ip) { + return inet_ntop(AF_INET, &ip, addr_str, INET6_ADDRSTRLEN); + } else { + return inet_ntop(AF_INET6, addr, addr_str, INET6_ADDRSTRLEN); + } +} struct in6_addr ipv6_addr_bitand(const struct in6_addr *src, const struct in6_addr *mask); struct in6_addr ipv6_addr_bitxor(const struct in6_addr *a, @@ -1616,7 +1637,13 @@ bool ipv6_is_cidr(const struct in6_addr *netmask); bool ipv6_addr_equals_masked(const struct in6_addr *a, const struct in6_addr *b, int plen); -bool ipv6_parse(const char *s, struct in6_addr *ip); +/* Parses string 's', which must be an IPv6 address. Stores the IPv6 address + * into '*ip'. Returns true if successful, otherwise false. */ +static inline bool +ipv6_parse(const char *s, struct in6_addr *ip) +{ + return inet_pton(AF_INET6, s, ip) == 1; +} char *ipv6_parse_masked(const char *s, struct in6_addr *ipv6, struct in6_addr *mask); char *ipv6_parse_cidr(const char *s, struct in6_addr *ip, unsigned int *plen) diff --git a/ovsdb/automake.mk b/ovsdb/automake.mk index d484fe9de..de9489442 100644 --- a/ovsdb/automake.mk +++ b/ovsdb/automake.mk @@ -63,7 +63,7 @@ MAN_FRAGMENTS += ovsdb/ovsdb-schemas.man # ovsdb-tool bin_PROGRAMS += ovsdb/ovsdb-tool ovsdb_ovsdb_tool_SOURCES = ovsdb/ovsdb-tool.c -ovsdb_ovsdb_tool_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la +ovsdb_ovsdb_tool_LDADD = ovsdb/libovsdb.la lib/libopenvswitchutils.la # ovsdb-tool.1 man_MANS += ovsdb/ovsdb-tool.1 CLEANFILES += ovsdb/ovsdb-tool.1 @@ -72,7 +72,7 @@ MAN_ROOTS += ovsdb/ovsdb-tool.1.in # ovsdb-client bin_PROGRAMS += ovsdb/ovsdb-client ovsdb_ovsdb_client_SOURCES = ovsdb/ovsdb-client.c -ovsdb_ovsdb_client_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la +ovsdb_ovsdb_client_LDADD = ovsdb/libovsdb.la lib/libopenvswitchutils.la # ovsdb-client.1 man_MANS += ovsdb/ovsdb-client.1 CLEANFILES += ovsdb/ovsdb-client.1 @@ -81,7 +81,7 @@ MAN_ROOTS += ovsdb/ovsdb-client.1.in # ovsdb-server sbin_PROGRAMS += ovsdb/ovsdb-server ovsdb_ovsdb_server_SOURCES = ovsdb/ovsdb-server.c -ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la +ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.la lib/libopenvswitchutils.la # ovsdb-server.1 man_MANS += ovsdb/ovsdb-server.1 CLEANFILES += ovsdb/ovsdb-server.1 diff --git a/python/setup.py.template b/python/setup.py.template index 89e80eed4..bd0ef1940 100644 --- a/python/setup.py.template +++ b/python/setup.py.template @@ -69,7 +69,7 @@ class try_build_ext(build_ext): if os.environ.get('enable_shared', '') == 'no': libraries = [] else: - libraries = ['openvswitch'] + libraries = ['openvswitchutils'] extra_cflags = os.environ.get('extra_cflags', '').split() extra_libs = os.environ.get('extra_libs', '').split() diff --git a/tests/automake.mk b/tests/automake.mk index 2f3e4f7ef..3265a5838 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -441,12 +441,12 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac noinst_PROGRAMS += tests/test-ovsdb tests_test_ovsdb_SOURCES = tests/test-ovsdb.c nodist_tests_test_ovsdb_SOURCES = tests/idltest.c tests/idltest.h -tests_test_ovsdb_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la +tests_test_ovsdb_LDADD = ovsdb/libovsdb.la lib/libopenvswitchutils.la noinst_PROGRAMS += tests/test-lib tests_test_lib_SOURCES = \ tests/test-lib.c -tests_test_lib_LDADD = lib/libopenvswitch.la +tests_test_lib_LDADD = lib/libopenvswitchutils.la # idltest schema and IDL OVSIDL_BUILT += tests/idltest.c tests/idltest.h tests/idltest.ovsidl @@ -517,11 +517,11 @@ tests_ovstest_SOURCES += \ tests/test-psample.c endif -tests_ovstest_LDADD = lib/libopenvswitch.la +tests_ovstest_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la noinst_PROGRAMS += tests/test-stream tests_test_stream_SOURCES = tests/test-stream.c -tests_test_stream_LDADD = lib/libopenvswitch.la +tests_test_stream_LDADD = lib/libopenvswitchutils.la noinst_PROGRAMS += tests/test-strtok_r tests_test_strtok_r_SOURCES = tests/test-strtok_r.c diff --git a/tests/oss-fuzz/automake.mk b/tests/oss-fuzz/automake.mk index 2b116e7a5..baff3d3ef 100644 --- a/tests/oss-fuzz/automake.mk +++ b/tests/oss-fuzz/automake.mk @@ -11,37 +11,37 @@ oss-fuzz-targets: $(OSS_FUZZ_TARGETS) tests_oss_fuzz_flow_extract_target_SOURCES = \ tests/oss-fuzz/flow_extract_target.c \ tests/oss-fuzz/fuzzer.h -tests_oss_fuzz_flow_extract_target_LDADD = lib/libopenvswitch.la +tests_oss_fuzz_flow_extract_target_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la tests_oss_fuzz_flow_extract_target_LDFLAGS = $(LIB_FUZZING_ENGINE) -lc++ tests_oss_fuzz_json_parser_target_SOURCES = \ tests/oss-fuzz/json_parser_target.c \ tests/oss-fuzz/fuzzer.h -tests_oss_fuzz_json_parser_target_LDADD = lib/libopenvswitch.la +tests_oss_fuzz_json_parser_target_LDADD = lib/libopenvswitchutils.la tests_oss_fuzz_json_parser_target_LDFLAGS = $(LIB_FUZZING_ENGINE) -lc++ tests_oss_fuzz_ofp_print_target_SOURCES = \ tests/oss-fuzz/ofp_print_target.c \ tests/oss-fuzz/fuzzer.h -tests_oss_fuzz_ofp_print_target_LDADD = lib/libopenvswitch.la +tests_oss_fuzz_ofp_print_target_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la tests_oss_fuzz_ofp_print_target_LDFLAGS = $(LIB_FUZZING_ENGINE) -lc++ tests_oss_fuzz_odp_target_SOURCES = \ tests/oss-fuzz/odp_target.c \ tests/oss-fuzz/fuzzer.h -tests_oss_fuzz_odp_target_LDADD = lib/libopenvswitch.la +tests_oss_fuzz_odp_target_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la tests_oss_fuzz_odp_target_LDFLAGS = $(LIB_FUZZING_ENGINE) -lc++ tests_oss_fuzz_miniflow_target_SOURCES = \ tests/oss-fuzz/miniflow_target.c \ tests/oss-fuzz/fuzzer.h -tests_oss_fuzz_miniflow_target_LDADD = lib/libopenvswitch.la +tests_oss_fuzz_miniflow_target_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la tests_oss_fuzz_miniflow_target_LDFLAGS = $(LIB_FUZZING_ENGINE) -lc++ tests_oss_fuzz_ofctl_parse_target_SOURCES = \ tests/oss-fuzz/ofctl_parse_target.c \ tests/oss-fuzz/fuzzer.h -tests_oss_fuzz_ofctl_parse_target_LDADD = lib/libopenvswitch.la +tests_oss_fuzz_ofctl_parse_target_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la tests_oss_fuzz_ofctl_parse_target_LDFLAGS = $(LIB_FUZZING_ENGINE) -lc++ EXTRA_DIST += \ diff --git a/tests/test-lib.c b/tests/test-lib.c index bcb5bb782..223077fca 100644 --- a/tests/test-lib.c +++ b/tests/test-lib.c @@ -22,7 +22,6 @@ #include <openvswitch/thread.h> #include <openvswitch/types.h> #include <openvswitch/util.h> -#include <openvswitch/vconn.h> #include <openvswitch/vlog.h> static void diff --git a/utilities/automake.mk b/utilities/automake.mk index 840eaec94..be3ac630f 100644 --- a/utilities/automake.mk +++ b/utilities/automake.mk @@ -111,26 +111,27 @@ man_MANS += \ utilities/ovs-vsctl.8 utilities_ovs_appctl_SOURCES = utilities/ovs-appctl.c -utilities_ovs_appctl_LDADD = lib/libopenvswitch.la +utilities_ovs_appctl_LDADD = lib/libopenvswitchutils.la utilities_ovs_testcontroller_SOURCES = utilities/ovs-testcontroller.c -utilities_ovs_testcontroller_LDADD = lib/libopenvswitch.la $(SSL_LIBS) +utilities_ovs_testcontroller_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la $(SSL_LIBS) utilities_ovs_dpctl_SOURCES = utilities/ovs-dpctl.c -utilities_ovs_dpctl_LDADD = lib/libopenvswitch.la +utilities_ovs_dpctl_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la utilities_ovs_ofctl_SOURCES = utilities/ovs-ofctl.c utilities_ovs_ofctl_LDADD = \ ofproto/libofproto.la \ - lib/libopenvswitch.la + lib/libopenvswitch.la \ + lib/libopenvswitchutils.la utilities_ovs_vsctl_SOURCES = utilities/ovs-vsctl.c -utilities_ovs_vsctl_LDADD = lib/libopenvswitch.la +utilities_ovs_vsctl_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la if LINUX noinst_PROGRAMS += utilities/nlmon utilities_nlmon_SOURCES = utilities/nlmon.c -utilities_nlmon_LDADD = lib/libopenvswitch.la +utilities_nlmon_LDADD = lib/libopenvswitch.la lib/libopenvswitchutils.la endif FLAKE8_PYFILES += utilities/ovs-pcap.in \ diff --git a/vswitchd/automake.mk b/vswitchd/automake.mk index 830c9a188..9f3f26bdd 100644 --- a/vswitchd/automake.mk +++ b/vswitchd/automake.mk @@ -12,7 +12,8 @@ vswitchd_ovs_vswitchd_SOURCES = \ vswitchd_ovs_vswitchd_LDADD = \ ofproto/libofproto.la \ lib/libsflow.la \ - lib/libopenvswitch.la + lib/libopenvswitch.la \ + lib/libopenvswitchutils.la vswitchd_ovs_vswitchd_LDFLAGS = $(AM_LDFLAGS) $(DPDK_vswitchd_LDFLAGS) MAN_ROOTS += vswitchd/ovs-vswitchd.8.in diff --git a/vtep/automake.mk b/vtep/automake.mk index e549922d9..e513abeea 100644 --- a/vtep/automake.mk +++ b/vtep/automake.mk @@ -34,7 +34,7 @@ man_MANS += \ vtep/vtep-ctl.8 vtep_vtep_ctl_SOURCES = vtep/vtep-ctl.c -vtep_vtep_ctl_LDADD = vtep/libvtep.la lib/libopenvswitch.la +vtep_vtep_ctl_LDADD = vtep/libvtep.la lib/libopenvswitchutils.la # ovs-vtep scripts_SCRIPTS += \ -- 2.54.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
