sliver-openvswitch.git
11 years agoMerge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch
Giuseppe Lettieri [Tue, 11 Sep 2012 13:36:45 +0000 (15:36 +0200)]
Merge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch

Conflicts:
planetlab/exp-tool/Makefile
planetlab/scripts/sliver-ovs

11 years agouse sliver-ovs to stop stuff as well
Thierry Parmentelat [Tue, 11 Sep 2012 13:01:33 +0000 (15:01 +0200)]
use sliver-ovs to stop stuff as well

11 years agosingle config file - LINKS get defined in conf.mk
Thierry Parmentelat [Tue, 11 Sep 2012 12:32:26 +0000 (14:32 +0200)]
single config file - LINKS get defined in conf.mk
this breaks the feature that lets save current topology but makes
user's - esp. firtst-time user's - life much easier
also an attempt to make the Makefile less cryptic :)

11 years agobugfix - create-port was broken
Thierry Parmentelat [Tue, 11 Sep 2012 12:30:34 +0000 (14:30 +0200)]
bugfix - create-port was broken

11 years agokill pltap-ovs on create-bridge timeout
Giuseppe Lettieri [Tue, 11 Sep 2012 12:27:56 +0000 (14:27 +0200)]
kill pltap-ovs on create-bridge timeout

11 years agoshow subcommand to inspect bridge configuration
Giuseppe Lettieri [Tue, 11 Sep 2012 11:38:29 +0000 (13:38 +0200)]
show subcommand to inspect bridge configuration

11 years agogeneric function for checking subcommand params
Giuseppe Lettieri [Tue, 11 Sep 2012 11:30:43 +0000 (13:30 +0200)]
generic function for checking subcommand params

11 years agofixed parameters for del-port
Giuseppe Lettieri [Tue, 11 Sep 2012 08:36:46 +0000 (10:36 +0200)]
fixed parameters for del-port

11 years agoadd set-remote-endpoint action to sliver-ovs
Giuseppe Lettieri [Tue, 11 Sep 2012 07:56:29 +0000 (09:56 +0200)]
add set-remote-endpoint action to sliver-ovs

Now all makefile targets call a sliver-ovs action.
This is required to centralize checks (is_{switch,db}_running and
possibly more to come) and to make all
sliver-openvwitch configuration variables (DB_SOCK and the like)
available to all actions.

11 years agoadd set-remote-endpoint action to sliver-ovs
Giuseppe Lettieri [Tue, 11 Sep 2012 07:56:29 +0000 (09:56 +0200)]
add set-remote-endpoint action to sliver-ovs

Now all makefile targets call a sliver-ovs action.
This is required to centralize checks (is_{switch,db}_running and
possibly more to come) and to make all
sliver-openvwitch configuration variables (DB_SOCK and the like)
available to all actions.

11 years agoMerge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch
Giuseppe Lettieri [Tue, 11 Sep 2012 07:49:04 +0000 (09:49 +0200)]
Merge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch

Conflicts:
planetlab/scripts/sliver-ovs

11 years agoINSTALL: Recommend installing kernel modules with "make modules_install".
Ben Pfaff [Mon, 10 Sep 2012 17:13:07 +0000 (10:13 -0700)]
INSTALL: Recommend installing kernel modules with "make modules_install".

Reported-by: Valentin Bud <valentin@hackaserver.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoache/bridge.% needs to contain the ifname
Thierry Parmentelat [Mon, 10 Sep 2012 12:30:10 +0000 (14:30 +0200)]
ache/bridge.% needs to contain the ifname

11 years agomore convenience targets, like
Thierry Parmentelat [Mon, 10 Sep 2012 08:52:16 +0000 (10:52 +0200)]
more convenience targets, like
make showips
and all the family of (assuming MUX is a host id) start.MUX stop.MUX
bridge.MUX and the like

11 years agospecifying the --db option to ovs-vsctl requires the unix: qualifier
Thierry Parmentelat [Mon, 10 Sep 2012 08:51:09 +0000 (10:51 +0200)]
specifying the --db option to ovs-vsctl requires the unix: qualifier

11 years agoadditional checks for running servers
Giuseppe Lettieri [Sat, 8 Sep 2012 16:51:40 +0000 (18:51 +0200)]
additional checks for running servers

- Added some more is_switch_running calls.
- Added new is_db_running. We need at least
  a running ovsdb-server to actually delete
  a port or a bridge.

11 years agojsonrpc: Treat receiving part of a message as activity.
Ben Pfaff [Wed, 5 Sep 2012 20:34:35 +0000 (13:34 -0700)]
jsonrpc: Treat receiving part of a message as activity.

Until now, the jsonrpc code has only counted receiving a full JSON-RPC
messages as activity.  This could theoretically time out, then, while a
very long message is in transit or if a slow link is involved.  This commit
changes this code to count receiving any part of a message as activity.

This isn't a problem for OpenFlow connections because OpenFlow messages are
at most 64 kB in size.

This problem hasn't actually been observed in practice.

Bug #12789.
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agojsonrpc: Treat draining data from send queue as activity.
Ben Pfaff [Fri, 7 Sep 2012 17:50:15 +0000 (10:50 -0700)]
jsonrpc: Treat draining data from send queue as activity.

Until now, the jsonrpc module has used messages received from the
remote peer as the sole means to determine that the JSON-RPC
connection is up.  This could in theory interact badly with a
remote peer that stops reading and processing messages from the
receive queue when there is a backlog in the send queue for a
given connection (ovsdb-server is an example of a program that
behaves this way).  This commit fixes the problem by expanding
the definition of "activity" to include successfully sending
JSON-RPC data that was previously queued.

The above change is exactly analogous to the similar change
made to the rconn library in commit 133f2dc95454 (rconn: Treat
draining a message from the send queue as activity.).

Bug #12789.
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoreconnect: Rename reconnect_received() to reconnect_activity().
Ben Pfaff [Wed, 8 Aug 2012 20:32:57 +0000 (13:32 -0700)]
reconnect: Rename reconnect_received() to reconnect_activity().

Receiving data is not the only reasonable way to verify that a connection
is up.  For example, on a TCP connection, receiving an acknowledgment that
the remote side has accepted data that we sent is also a reasonable means.
Therefore, this commit generalizes the naming.

Also, similarly for the Python implementation: Reconnect.received() becomes
Reconnect.activity().

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoadd timeouts to infinite loops
Thierry Parmentelat [Fri, 7 Sep 2012 07:33:50 +0000 (09:33 +0200)]
add timeouts to infinite loops

11 years agoadd global start stop status targets for handling db+switch
Thierry Parmentelat [Fri, 7 Sep 2012 06:46:09 +0000 (08:46 +0200)]
add global start stop status targets for handling db+switch

11 years agospecify DB_SOCKET to ovs-vsctl for consistency
Thierry Parmentelat [Fri, 7 Sep 2012 06:45:10 +0000 (08:45 +0200)]
specify DB_SOCKET to ovs-vsctl for consistency
use /etc/openvswitch instead of /usr/etc/openvswitch

11 years agotweak packaging to use fedora-compliant paths
Thierry Parmentelat [Fri, 7 Sep 2012 06:42:44 +0000 (08:42 +0200)]
tweak packaging to use fedora-compliant paths
remove duplicate sliver-ovs script

11 years agoadd netmask in the example file
Thierry Parmentelat [Fri, 7 Sep 2012 06:11:35 +0000 (08:11 +0200)]
add netmask in the example file

11 years agostores command logs in separate file, not the make target itself
Thierry Parmentelat [Thu, 6 Sep 2012 16:04:19 +0000 (18:04 +0200)]
stores command logs in separate file, not the make target itself

11 years agonew subcommands start stop status
Thierry Parmentelat [Thu, 6 Sep 2012 16:03:47 +0000 (18:03 +0200)]
new subcommands start stop status

11 years agospecify where the switch daemon creates its control socket and pass
Thierry Parmentelat [Thu, 6 Sep 2012 15:38:55 +0000 (17:38 +0200)]
specify where the switch daemon creates its control socket and pass
this to ovs-appctl

11 years agorun sudo with -S is required for f14 (was not on f12)
Thierry Parmentelat [Thu, 6 Sep 2012 14:38:38 +0000 (16:38 +0200)]
run sudo with -S is required for f14 (was not on f12)
rename switchd into just switch, for consistency with sliver-ovs

11 years agoadd stop_* and status commands
Thierry Parmentelat [Thu, 6 Sep 2012 11:25:21 +0000 (13:25 +0200)]
add stop_* and status commands
fix communication between db and switch
all filenames are variables
specify logfiles

11 years agoautomake was whining
Thierry Parmentelat [Thu, 6 Sep 2012 06:32:33 +0000 (08:32 +0200)]
automake was whining

11 years agoMerge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch
Thierry Parmentelat [Thu, 6 Sep 2012 06:25:57 +0000 (08:25 +0200)]
Merge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch

11 years agoadd solve_ip function
Thierry Parmentelat [Thu, 6 Sep 2012 06:25:48 +0000 (08:25 +0200)]
add solve_ip function

11 years agofix dependencies after scripts cleanup
Thierry Parmentelat [Thu, 6 Sep 2012 06:25:32 +0000 (08:25 +0200)]
fix dependencies after scripts cleanup

11 years agothird-party: Fix tcpdump patch
Joe Stringer [Wed, 5 Sep 2012 03:25:58 +0000 (15:25 +1200)]
third-party: Fix tcpdump patch

Other parts of OVS have moved on since the tcpdump patch was created. This
commit brings the patch up to date and will compile cleanly against
tcpdump-4.3.0.

Signed-off-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
11 years agodpif-linux: Report packet loss as WARN instead of ERR.
Ben Pfaff [Wed, 5 Sep 2012 18:02:27 +0000 (11:02 -0700)]
dpif-linux: Report packet loss as WARN instead of ERR.

Packet loss is recoverable so it doesn't warrant an ERR.

Bug #12920.
Reported-by: Scott Hendricks <shendricks@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoovsdb: Enforce immutability of immutable columns.
Ben Pfaff [Wed, 5 Sep 2012 17:35:20 +0000 (10:35 -0700)]
ovsdb: Enforce immutability of immutable columns.

OVSDB has always had the ability to mark a column as "immutable", so that
its value cannot be changed in a given row after that row is initially
inserted.  However, we discovered recently that ovsdb-server has never
enforced this constraint.  This commit implements enforcement.

Reported-by: Paul Ingram <paul@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
11 years agomake the separator configurable
Giuseppe Lettieri [Wed, 5 Sep 2012 17:33:01 +0000 (19:33 +0200)]
make the separator configurable

11 years agoofp-errors: Use OFPERR_OFPBRC_BAD_TABLE_ID
Simon Horman [Wed, 5 Sep 2012 02:50:38 +0000 (11:50 +0900)]
ofp-errors: Use OFPERR_OFPBRC_BAD_TABLE_ID

* In the case of OpenFlow 1.1+ OFPERR_OFPBRC_BAD_TABLE_ID is defined
  in the specification and seems to be the most appropriate error
  to use when an unknown table id is encountered.

* In the case of OpenFlow 1.0 no appropriate error message
  seems to exist. Perhaps because an invalid port is not possible?
  I'm unsure.

  In any case, make use of a non-standard error code (1,512).
  This was formerly known as OFPERR_NXBRC_BAD_TABLE_ID but
  has been rolled into OFPERR_OFPBRC_BAD_TABLE_ID to allow the
  latter to be used without concern for the prevailing Open Flow version.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofp-errors: Use OFPERR_OFPBRC_BAD_PORT
Simon Horman [Wed, 5 Sep 2012 02:50:37 +0000 (11:50 +0900)]
ofp-errors: Use OFPERR_OFPBRC_BAD_PORT

* In the case of OpenFlow 1.2+ OFPERR_OFPBRC_BAD_PORT is defined
  in the specification and seems to be the most appropriate error
  to use when an invalid port is encountered in a Packet Out request.

* In the case of OpenFlow 1.0 and 1.1 no appropriate error message
  seems to exist. Perhaps because an invalid port is not possible?
  I'm unsure.

  In any case, make use of a non-standard error code (1,514).
  This was formerly known as OFPERR_NXBRC_BAD_IN_PORT but
  has been rolled into OFPERR_NXBRC_BAD_IN_PORT to allow the
  latter to be used without concern for the prevailing Open Flow version.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoextract-ofp-errors: Check that error codes are in the expected ranges.
Ben Pfaff [Wed, 5 Sep 2012 17:18:56 +0000 (10:18 -0700)]
extract-ofp-errors: Check that error codes are in the expected ranges.

All real OpenFlow error codes are small numbers, and for Nicira extensions
we've intentionally chosen large numbers.  This commit adds a check that
standard and extension codes are properly designated in the ofp-errors.h
header.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofp-errors: Ignore text enclosed in square brackets
Simon Horman [Wed, 5 Sep 2012 02:50:36 +0000 (11:50 +0900)]
ofp-errors: Ignore text enclosed in square brackets

Enhance to extract-ofp-errors to omit text enclosed in square brackets from
error description. This allows some commentary other than
the error description to be supplied in ofp-errors.h

As suggested by Ben Pfaff <blp@nicira.com>

Signed-off-by: Simon Horman <horms@verge.net.au>
[blp@nicira.com added the large comment on enum ofperr.]
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agopython/ovs/poller: use select.select instead of select.poll.
Isaku Yamahata [Wed, 5 Sep 2012 10:38:26 +0000 (19:38 +0900)]
python/ovs/poller: use select.select instead of select.poll.

eventlet/gevent doesn't work well with select.poll because select.poll blocks
python interpreter as a whole instead of switching from the current thread
which is about to block to other runnable thread.
So ovsdb python binding can't be used with eventlet/gevent.
Emulate select.poll with select.select because using python means that
performance isn't so important.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agobugfixes
Thierry Parmentelat [Wed, 5 Sep 2012 14:35:43 +0000 (16:35 +0200)]
bugfixes

11 years agotrash old scripts
Thierry Parmentelat [Wed, 5 Sep 2012 14:10:36 +0000 (16:10 +0200)]
trash old scripts

11 years agocosmetic in usage message
Thierry Parmentelat [Wed, 5 Sep 2012 14:08:23 +0000 (16:08 +0200)]
cosmetic in usage message

11 years agouse sliver-ovs <subcommand> rather than the former scripts
Thierry Parmentelat [Wed, 5 Sep 2012 14:08:10 +0000 (16:08 +0200)]
use sliver-ovs <subcommand> rather than the former scripts

11 years agofirst attempt at a single merged script out of the previous 6
Thierry Parmentelat [Wed, 5 Sep 2012 14:03:16 +0000 (16:03 +0200)]
first attempt at a single merged script out of the previous 6

11 years agotargets shownodes and showslice
Thierry Parmentelat [Wed, 5 Sep 2012 12:51:23 +0000 (14:51 +0200)]
targets shownodes and showslice

11 years agomake room for a private myexp/ dir
Thierry Parmentelat [Wed, 5 Sep 2012 12:51:01 +0000 (14:51 +0200)]
make room for a private myexp/ dir

11 years agoremove extraneous sequel from merge
Thierry Parmentelat [Wed, 5 Sep 2012 11:49:06 +0000 (13:49 +0200)]
remove extraneous sequel from merge

11 years agoMerge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch
Giuseppe Lettieri [Wed, 5 Sep 2012 10:36:29 +0000 (12:36 +0200)]
Merge branch 'master' of ssh://git.onelab.eu/git/sliver-openvswitch

11 years agoMerge branch 'forward-port'
Giuseppe Lettieri [Wed, 5 Sep 2012 10:35:36 +0000 (12:35 +0200)]
Merge branch 'forward-port'

Conflicts:
planetlab/exp-tool/Makefile

11 years agoimprove make nodes
Thierry Parmentelat [Wed, 5 Sep 2012 08:56:39 +0000 (10:56 +0200)]
improve make nodes

11 years agolib/ofp-util: preparation for OF12 of ofp-util
Simon Horman [Tue, 4 Sep 2012 01:32:48 +0000 (10:32 +0900)]
lib/ofp-util: preparation for OF12 of ofp-util

Add necessary macros to ofp-util for OF12 support.
This is just a placeholder.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofp-errors: Use standardised code for OFPERR_OFPBMC_BAD_VALUE
Simon Horman [Tue, 4 Sep 2012 06:52:03 +0000 (15:52 +0900)]
ofp-errors: Use standardised code for OFPERR_OFPBMC_BAD_VALUE

Use standardised code for Open Flow 1.1 OFPERR_OFPBMC_BAD_VALUE

OFPERR_OFPBMC_BAD_VALUE is defined in Open Flow 1.1 as (4,7),
so use that code instead of a non-standard one.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofp-errors: Remove OFPERR_NXFMFC_GROUPS_NOT_SUPPORTED
Simon Horman [Tue, 4 Sep 2012 06:52:00 +0000 (15:52 +0900)]
ofp-errors: Remove OFPERR_NXFMFC_GROUPS_NOT_SUPPORTED

OFPERR_NXFMFC_GROUPS_NOT_SUPPORTED is currently only used in paths which
are part of a non-NX extension portions of the Open Flow 1.1+
implementation.

After recent discussion it has been decided to attempt to only use
standardised, albeit lest-specify, errors unless errors arise from use of
an NX extension.

With the above in mind it seems appropriate to:
* Use OFPERR_OFPFMFC_UNKNOWN in place of OFPERR_NXFMFC_GROUPS_NOT_SUPPORTED.
* Remove OFPERR_NXFMFC_GROUPS_NOT_SUPPORTED as it is no longer used.

An unfortunate side-effect of this change is that the error for
the case in question is now less-specific.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofp-errors: Remove OFPERR_NXBIC_DUP_TYPE
Simon Horman [Tue, 4 Sep 2012 06:51:59 +0000 (15:51 +0900)]
ofp-errors: Remove OFPERR_NXBIC_DUP_TYPE

OFPERR_NXBIC_DUP_TYPE is currently only used in
decode_openflow11_instructions() which is part of a non-NX extension
portion of the Open Flow 1.1+ implementation.

After recent discussion it has been decided to attempt to only use
standardised, albeit less-specific, errors unless errors arise from use of
an NX extension.

With the above in mind it seems appropriate to:
* Use OFPERR_OFPIT_BAD_INSTRUCTION in place of OFPERR_NXBIC_DUP_TYPE.
* Remove OFPERR_NXBIC_DUP_TYPE as it is no longer used.

An unfortunate side-effect of this change is that the error for
the case in question is now less-specific.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoIntroduce sparse flows and masks, to reduce memory usage and improve speed.
Ben Pfaff [Tue, 4 Sep 2012 19:43:53 +0000 (12:43 -0700)]
Introduce sparse flows and masks, to reduce memory usage and improve speed.

A cls_rule is 324 bytes on i386 now.  The cost of a flow table lookup is
currently proportional to this size, which is going to continue to grow.
However, the required cost of a flow table lookup, with the classifier that
we currently use, is only proportional to the number of bits that a rule
actually matches.  This commit implements that optimization by replacing
the match inside "struct cls_rule" by a sparse representation.

This reduces struct cls_rule to 100 bytes on i386.

There is still some headroom for further optimization following this
commit:

    - I suspect that adding an 'n' member to struct miniflow would make
      miniflow operations faster, since popcount() has some cost.

    - It's probably possible to replace the "struct minimatch" in cls_rule
      by just a "struct miniflow", since the cls_rule's cls_table has a
      copy of the minimask.

    - Some of the miniflow operations aren't well-optimized.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agohash: Introduce an implementation of murmurhash.
Ben Pfaff [Tue, 21 Aug 2012 21:26:23 +0000 (14:26 -0700)]
hash: Introduce an implementation of murmurhash.

Murmurhash is generally superior to the Jenkins lookup3 hash according to
the available figures.  Perhaps we should generally replace our current
hashes by murmurhash.

For now, I'm introducing a parallel implementation to allow it to be used
in cases where an incremental one-word-at-a-time hash is desirable.  The
first user will be added in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agoutil: New function raw_ctz().
Ben Pfaff [Tue, 21 Aug 2012 17:47:22 +0000 (10:47 -0700)]
util: New function raw_ctz().

This will acquire a user in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoclassifier: Optimize iteration with a catch-all target rule.
Ben Pfaff [Fri, 20 Jul 2012 21:46:15 +0000 (14:46 -0700)]
classifier: Optimize iteration with a catch-all target rule.

When cls_cursor_init() is given a NULL target, it can skip an expensive
step comparing the rule against the target for every table and every rule
in the classifier.  collect_rule_loose() and other callers could take
advantage of this optimization, except that they actually pass in a rule
that matches everything instead of a NULL rule (e.g. for "ovs-ofctl
dump-flows <bridge>" without specifying a matching rule).

This optimizes that case.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoclassifier: Prepare for "struct cls_rule" needing to be destroyed.
Ben Pfaff [Mon, 20 Aug 2012 18:29:43 +0000 (11:29 -0700)]
classifier: Prepare for "struct cls_rule" needing to be destroyed.

Until now, "struct cls_rule" didn't own any data outside its own memory
block.  An upcoming commit will make "struct cls_rule" sometimes own blocks
of memory, so it needs "destroy" and to a lesser extent "clone" functions.
This commit adds these in advance, even though they are mostly no-ops, to
make it possible to separately review the memory management.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoclassifier: Break cls_rule 'flow' and 'wc' members into new "struct match".
Ben Pfaff [Tue, 7 Aug 2012 22:28:18 +0000 (15:28 -0700)]
classifier: Break cls_rule 'flow' and 'wc' members into new "struct match".

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoclassifier: Fix typo in comment.
Ben Pfaff [Fri, 20 Jul 2012 21:54:30 +0000 (14:54 -0700)]
classifier: Fix typo in comment.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoutil: New function popcount().
Ben Pfaff [Fri, 20 Jul 2012 19:38:59 +0000 (12:38 -0700)]
util: New function popcount().

This is the fastest portable implementation among the ones below, as
measured with GCC 4.4 on a Xeon X3430.  The measeured times were, in
seconds:

popcount1    25.6
popcount2     6.9 (but is not portable)
popcount3    31.4
popcount4    25.6
popcount5    61.6 (and is buggy)
popcount6    64.6
popcount7    32.3
popcount8    11.2

int
popcount1(unsigned int x)
{
    return __builtin_popcount(x);
}

int
popcount2(unsigned int x)
{
    unsigned int y;
    asm("popcnt %1, %0" : "=r" (y) : "g" (x));
    return y;
}

int
popcount3(unsigned int x)
{
    unsigned int n;

    n = (x >> 1) & 033333333333;
    x -= n;
    n = (n >> 1) & 033333333333;
    x -= n;
    x = (x + (x >> 3)) & 030707070707;
    return x % 63;
}

int
popcount4(unsigned int x)
{
    x -= (x >> 1) & 0x55555555;
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
    x = (x + (x >> 4)) & 0x0f0f0f0f;
    x += x >> 8;
    x += x >> 16;
    return x & 0x3f;
}

int
popcount5(unsigned int x)
{
    int n;

    n = 0;
    while (x) {
        if (x & 0xf) {
            n += ((0xe9949440 >> (x & 0xf)) & 3) + 1;
        }
        x >>= 4;
    }
    return n;
}

int
popcount6(unsigned int x)
{
    int n;

    n = 0;
    while (x) {
        n += (0xe994 >> (x & 7)) & 3;
        x >>= 3;
    }
    return n;
}

int
popcount7(unsigned int x)
{
    static const int table[16] = {
        0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
    };

    return (table[x & 0xf]
            + table[(x >> 4) & 0xf]
            + table[(x >> 8) & 0xf]
            + table[(x >> 12) & 0xf]
            + table[(x >> 16) & 0xf]
            + table[(x >> 20) & 0xf]
            + table[(x >> 24) & 0xf]
            + table[x >> 28]);
}

static int
popcount8(unsigned int x)
{
    ((((X) & (1 << 0)) != 0) +                  \
     (((X) & (1 << 1)) != 0) +                  \
     (((X) & (1 << 2)) != 0) +                  \
     (((X) & (1 << 3)) != 0) +                  \
     (((X) & (1 << 4)) != 0) +                  \
     (((X) & (1 << 5)) != 0) +                  \
     (((X) & (1 << 6)) != 0) +                  \
     (((X) & (1 << 7)) != 0))

    static const uint8_t popcount8[256] = {
        INIT64(0), INIT64(64), INIT64(128), INIT64(192)
    };

    return (popcount8[x & 0xff] +
            popcount8[(x >> 8) & 0xff] +
            popcount8[(x >> 16) & 0xff] +
            popcount8[x >> 24]);
}

int
main(void)
{
    unsigned long long int x;
    int n;

    n = 0;
    for (x = 0; x <= UINT32_MAX; x++) {
        n += popcount8(x);
    }
    printf("%d\n", n);

    return 0;
}

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoutil: New function zero_rightmost_1bit().
Ben Pfaff [Fri, 20 Jul 2012 18:45:33 +0000 (11:45 -0700)]
util: New function zero_rightmost_1bit().

It's probably easier to understand
x = zero_rightmost_1bit(x);
than
x &= x - 1;

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Simplify many functions for working with flows and wildcards.
Ben Pfaff [Tue, 7 Aug 2012 20:43:18 +0000 (13:43 -0700)]
flow: Simplify many functions for working with flows and wildcards.

Now that "struct flow" and "struct flow_wildcards" have the same simple
and uniform structure, it's easy to handle common operations by just
iterating over the bits inside them.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Remove flow_wildcards_is_exact().
Ben Pfaff [Mon, 18 Jun 2012 22:46:13 +0000 (15:46 -0700)]
flow: Remove flow_wildcards_is_exact().

It's only used in a not-very-useful assertion in some test code.  In
general, exact-match flows make very little sense anymore, and they're
basically on their way out.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Replace flow_wildcards members by a single "struct flow".
Ben Pfaff [Tue, 7 Aug 2012 20:38:38 +0000 (13:38 -0700)]
flow: Replace flow_wildcards members by a single "struct flow".

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Take advantage of zero-padding in struct flow and flow_wildcards.
Ben Pfaff [Mon, 18 Jun 2012 22:12:57 +0000 (15:12 -0700)]
flow: Take advantage of zero-padding in struct flow and flow_wildcards.

Since we know these bytes are always 0 in both structures, we can use
faster functions that only work with full words.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Ensure that padding is always zeroed.
Ben Pfaff [Mon, 18 Jun 2012 22:09:49 +0000 (15:09 -0700)]
flow: Ensure that padding is always zeroed.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Use bit-mask for in_port match, instead of FWW_* flag.
Ben Pfaff [Fri, 3 Aug 2012 20:27:15 +0000 (13:27 -0700)]
flow: Use bit-mask for in_port match, instead of FWW_* flag.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Use bit-mask for Ethernet type match, instead of FWW_* flag.
Ben Pfaff [Mon, 18 Jun 2012 20:33:13 +0000 (13:33 -0700)]
flow: Use bit-mask for Ethernet type match, instead of FWW_* flag.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Use bit-mask for IP protocol match, instead of FWW_* flag.
Ben Pfaff [Mon, 18 Jun 2012 21:12:52 +0000 (14:12 -0700)]
flow: Use bit-mask for IP protocol match, instead of FWW_* flag.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Use bit-mask for TTL match, instead of FWW_* flag.
Ben Pfaff [Mon, 18 Jun 2012 18:36:03 +0000 (11:36 -0700)]
flow: Use bit-mask for TTL match, instead of FWW_* flag.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Use bit-mask for DSCP and ECN bits, instead of FWW_* flags.
Ben Pfaff [Mon, 18 Jun 2012 21:11:13 +0000 (14:11 -0700)]
flow: Use bit-mask for DSCP and ECN bits, instead of FWW_* flags.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoflow: Fully separate FWW_* from OFPFW10_*.
Ben Pfaff [Mon, 18 Jun 2012 16:55:22 +0000 (09:55 -0700)]
flow: Fully separate FWW_* from OFPFW10_*.

It might have been a useful optimization at one point to have FWW_*
correspond in OFPFW10_* where possible, but it doesn't seem worthwhile for
only 3 corresponding values.  It also makes the code somewhat more
confusing.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofproto: Move ofpacts_check() calls from ofproto-dpif to ofproto.
Ben Pfaff [Fri, 20 Jul 2012 01:25:02 +0000 (18:25 -0700)]
ofproto: Move ofpacts_check() calls from ofproto-dpif to ofproto.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofproto: Move 'max_ports' from ofproto-dpif.c to ofproto.c.
Ben Pfaff [Fri, 20 Jul 2012 01:30:12 +0000 (18:30 -0700)]
ofproto: Move 'max_ports' from ofproto-dpif.c to ofproto.c.

This allows port numbers in actions and elsewhere in OpenFlow messages to
be checked at a higher level.

Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agosmall improvements
Thierry Parmentelat [Tue, 4 Sep 2012 16:27:41 +0000 (18:27 +0200)]
small improvements

11 years agodatapath: Drop comment describing vport node.
Jesse Gross [Tue, 4 Sep 2012 02:22:03 +0000 (19:22 -0700)]
datapath: Drop comment describing vport node.

Commit f36ff26ac08bcba28b5befba7b1dcff9b963769d (datapath: Remove
vport list node.) removed an unused list node in struct vport but
did not remove the comment describing it.  This does that.

Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agodatapath: Fix FLOW_BUFSIZE definition.
Jesse Gross [Mon, 3 Sep 2012 22:15:01 +0000 (15:15 -0700)]
datapath: Fix FLOW_BUFSIZE definition.

This is analogous to the change made in userspace with
2508ac16defd417b94fb69689b6b1da4fbc76282 (odp-util: Update
ODPUTIL_FLOW_KEY_BYTES for current kernel flow format.).  The extra
space for vlan encapsulation was not included in the allocation for
maximum length flows.

Found by code inspection and to my knowledge has never been hit, likely
because skb allocations are padded out to a cacheline, making userspace
more susceptible to this problem than the kernel.  In theory, however,
the right combination of flow and packet size could result in a kernel
panic.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
11 years agodatapath: Remove vport list node.
Jesse Gross [Tue, 4 Sep 2012 00:15:03 +0000 (17:15 -0700)]
datapath: Remove vport list node.

The datapath list of ports was removed when we switched to using a
hash-based port lookup so the list node is no longer used.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
11 years agoadd -t option to ssh, to second sudo forward-port
Giuseppe Lettieri [Mon, 3 Sep 2012 12:36:12 +0000 (14:36 +0200)]
add -t option to ssh, to second sudo

11 years agodatapath: Fix typo
Joe Stringer [Fri, 31 Aug 2012 03:35:49 +0000 (15:35 +1200)]
datapath: Fix typo

Signed-off-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: Jesse Gross <jesse@nicira.com>
11 years agolockfile: Log more helpful message when locking fails due to a conflict.
Ben Pfaff [Fri, 31 Aug 2012 17:11:15 +0000 (10:11 -0700)]
lockfile: Log more helpful message when locking fails due to a conflict.

Reported-by: rahim entezari <rahim.entezari@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agolockfile: In tests, also verify log messages.
Ben Pfaff [Fri, 31 Aug 2012 17:10:13 +0000 (10:10 -0700)]
lockfile: In tests, also verify log messages.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
11 years agoupdate to new netdev interface
Giuseppe Lettieri [Thu, 30 Aug 2012 15:31:00 +0000 (17:31 +0200)]
update to new netdev interface

get/set config now use smap's instead of shash's

11 years agofix warnings about unused paramethers
Giuseppe Lettieri [Thu, 30 Aug 2012 15:28:19 +0000 (17:28 +0200)]
fix warnings about unused paramethers

11 years agoMerge branch 'master' into forward-port
Giuseppe Lettieri [Thu, 30 Aug 2012 14:35:26 +0000 (16:35 +0200)]
Merge branch 'master' into forward-port

Conflicts:
lib/automake.mk
lib/dpif-netdev.c
lib/netdev-provider.h
lib/netdev.c

11 years agolist files that do not go into the distribution
Giuseppe Lettieri [Thu, 30 Aug 2012 14:12:25 +0000 (16:12 +0200)]
list files that do not go into the distribution

The Makefile of Open vSwitch checks that all files in the
git repository are also distributed and stops with an error
otherwise. But we have some files in git that are not meant
to be distributed (i.e., installed on a sliver). These files can now
be listed in .non-distfiles and the new Makefile will ignore them.

11 years agofix obnoxiuos warnings
Giuseppe Lettieri [Thu, 30 Aug 2012 14:11:09 +0000 (16:11 +0200)]
fix obnoxiuos warnings

11 years agofix some warnings
Giuseppe Lettieri [Thu, 30 Aug 2012 13:31:57 +0000 (15:31 +0200)]
fix some warnings

11 years agovswitchd: Respect other_config:stp-enable port setting.
Ethan Jackson [Wed, 29 Aug 2012 23:00:31 +0000 (16:00 -0700)]
vswitchd: Respect other_config:stp-enable port setting.

Commit a699f614 (lib: Utilize smaps in the idl.) broke the
other_config:stp-enable port setting in two ways.  First, it
changed the default if the setting was missing to disabled.
Second, if the setting was present, it did the opposite of what the
user configured.

Bug #13122.
Reported-by: Paul Ingram <paul@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
11 years agoofproto-dpif: Make OFPP_TABLE send packet-in on miss.
Isaku Yamahata [Tue, 28 Aug 2012 17:19:03 +0000 (02:19 +0900)]
ofproto-dpif: Make OFPP_TABLE send packet-in on miss.

The OpenFlow specification for OFPP_TABLE implies that a miss
should generate a packet-in, but Open vSwitch has never done
that.  This corrects the behavior.

This also prepares for the goto-table instruction, which will
need to generate a table-miss in some circumstances.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
[blp@nicira.com rebased and updated commit message]
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofp-msgs: Allow encoding and decoding of Open Flow 1.1 & 1.2 Barrier Messages
Simon Horman [Tue, 21 Aug 2012 04:55:38 +0000 (13:55 +0900)]
ofp-msgs: Allow encoding and decoding of Open Flow 1.1 & 1.2 Barrier Messages

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoovs-ofctl: Use vconn as a parameter of dump_stats_transaction()
Simon Horman [Tue, 21 Aug 2012 04:55:37 +0000 (13:55 +0900)]
ovs-ofctl: Use vconn as a parameter of dump_stats_transaction()

In order to form a stats message for the prevailing OpenFlow version
of a vconn the vconn needs to be open at the time the request is
encoded. Thus there is no longer a case where it makes sense to
use dump_stats_transaction() without a vconn already being open and
available to pass as a parameter.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofp-msgs: Split OFPRAW_OFPST_AGGREGATE_REQUEST
Simon Horman [Tue, 21 Aug 2012 04:55:35 +0000 (13:55 +0900)]
ofp-msgs: Split OFPRAW_OFPST_AGGREGATE_REQUEST

Split OFPRAW_OFPST_AGGREGATE_REQUEST into OpenFlow 1.0 and 1.1+
versions.

This should be sufficient to allow adding encoding and decoding of
Open Flow 1.1 and 1.2 Aggregate Stats Request messages.

Encoding and decoding of Open Flow 1.1 and 1.2 Aggregate Stats Response
messages works using the existing code without modification.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofp-util: Allow decoding of Open Flow 1.2 Flow Statistics Request Messages
Simon Horman [Tue, 21 Aug 2012 04:55:34 +0000 (13:55 +0900)]
ofp-util: Allow decoding of Open Flow 1.2 Flow Statistics Request Messages

Allow decoding of Open Flow 1.1 and 1.2 flow statistics request messages.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
11 years agoofproto-dpif: refactor rule_dpif_lookup() for table miss whose id > 0
Isaku Yamahata [Tue, 28 Aug 2012 17:19:02 +0000 (02:19 +0900)]
ofproto-dpif: refactor rule_dpif_lookup() for table miss whose id > 0

The refactored function, rule_dpif_miss_rule(), will be used for
handling table miss whose table_id > 0 by goto-table instruction.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>