[ovs-discuss] Using libopenvswitch in C++

Ben Pfaff blp at ovn.org
Mon Jul 31 02:56:00 UTC 2017


On Sun, Jul 30, 2017 at 08:33:41AM -0700, Ben Warren via discuss wrote:
> Hello Xiao,
> 
> > On Jul 29, 2017, at 11:30 PM, Xiao Liang <shaw.leon at gmail.com> wrote:
> > 
> > Hi,
> > 
> > I've encountered some problems building a controller with
> > libopenvswitch in C++. Although they can be solved by some hacks, I
> > want to know if OVS is meant to be used in such case.
> > 
> I don’t think there are very many consumers of libopenvswitch.  It was only added a year and a half ago, and is rarely mentioned in discussions.  The exportability of OVS is definitely geared towards C (and, in my case golang), so it’s more likely the case that people simply weren’t thinking about C++ at the time.
> > 1. In include/openvswitch, some headers are wrapped with 'extern "C"'
> > (e.g. ofpbuf.h), while some are not (e.g. ofp-util.h).
> > 2. The identifier "public" in "struct ofputil_packet_in_private"
> > conflicts with C++ keyword. Not sure if there're others.
> > 3. Private and public declarations (like the
> > ofputil_packet_in_private) could be separated to different files. Also
> > some more APIs (like rconn) could be extracted from lib directory?
> > 
> I expect that the maintainers would accept patches to make the code more C++ friendly, as long as you don’t break the C/golang support.  I can test the latter.

I think that Open vSwitch can do better here.

I sent out a series, would you mind taking a look?  It starts here:
        https://mail.openvswitch.org/pipermail/ovs-dev/2017-July/336426.html


More information about the discuss mailing list