ofproto-dpif: Add more lock annotations.

This annotation would have caught the bug fixed by commit 491a67a0005347130
(ofproto-dpif-xlate: Avoid recursive acquisition of xlate_rwlock.).

Signed-off-by: Ben Pfaff <blp@nicira.com>
CC: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
ofproto-dpif-monitor: Change global rwlock into mutex.

Nothing ever took monitor_rwlock's read lock, so it might as well be a
mutex.

Signed-off-by: Ben Pfaff <blp@nicira.com>
tests: Fix path for distcleaning ovs-controller.8

Fixes the following error on distcheck:-

ERROR: files left in build directory after distclean:
./tests/test-controller.8
make[1]: *** [distcleancheck] Error 1

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
netdev_class: Pass a struct ofpbuf * to rx_recv()

Update the netdev_class so that struct ofpbuf * is passed to rx_recv()
to provide both the data and size of the data to read a packet into.

On success, update struct ofpbuf size inside netdev_class rx_recv
implementation and return 0. This moves logic from the caller.
On error a positive error code is returned, whereas previously
a negative error code was returned. This is a more common convention.

This patch should not have any behavioural changes.

This patch is in preparation for the netdev-linux variant of rx_recv()
making use of headroom in the struct ofpbuf * parameter to push a VLAN tag
obtained from auxdata.

Signed-off-by: Simon Horman <horms@verge.net.au>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib: Add tpid parameter to eth_push_vlan()

This is in preparation for pushing vlan tags
using the TPID provided by the kernel via auxdata.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
netdev-linux: Read packet auxdata to obtain vlan_tid

If VLAN acceleration is used when the kernel receives a packet
then the outer-most VLAN tag will not be present in the packet
when it is received by netdev-linux. Rather, it will be present
in auxdata.

This patch uses recvmsg() instead of recv() to read auxdata for
each packet and if the vlan_tid is set then it is added to the packet.

Adding the vlan_tid makes use of headroom available
in the buffer parameter of rx_recv.

Signed-off-by: Simon Horman <horms@verge.net.au>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
vswitchd: Inherit parents mac address for fake bridges

When adding a physical port to the main bridge the mac address
of the bridge is updated. We can do the same for fake bridges by
copying the mac address of the parent bridge.

There exists only one fake bridge per vlan, hence it is safe
to copy the mac address of the parent bridge.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
netdev-linux: Fix build break on RHEL 6.1.

Commit 73c85181d (netdev-linux: Read packet auxdata to obtain vlan_tid)
added #include <linux/if_packet.h> to this file, to get the definition
of PACKET_AUXDATA and some other definitions, but on RHEL 6.1 this
provoked compiler errors:

In file included from /usr/include/linux/rtnetlink.h:5,
    from lib/netdev-linux.c:34:
/usr/include/linux/netlink.h:34: error: expected specifier-qualifier-list
    before 'sa_family_t'

Since the old #includes worked everywhere, and this file already defined
its own versions of most of the new macros that it needed, this commit just
reverts the old #includes and adds the one macro definition it didn't
already have.

(RHEL 6.1 isn't necessarily the only platform where this is a problem, but
it's the first one for which we noticed the problem.)

This switches the definition of sockaddr_ll used from the Linux one, which
uses __be16 for sll_protocol, to the glibc one, which uses plain "unsigned
short int".  This makes sparse complain (rightly), so this commit also
adds a sparse-specific header that uses ovs_be16 to prevent the warning.

Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: Fix kernel panic on ovs_flow_free

Both mega flow mask's reference counter and per flow table mask list
should only be accessed when holding ovs_mutex() lock. However
this is not true with ovs_flow_table_flush(). The patch fixes this bug.

Reported-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>