Skip to content

Commit

Permalink
Merge citrix branch into master.
Browse files Browse the repository at this point in the history
  • Loading branch information
blp committed Sep 22, 2009
2 parents 2a6cb30 + 36beceb commit 576e26d
Show file tree
Hide file tree
Showing 25 changed files with 565 additions and 92 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
v0.90.5 - 21 Sep 2009
---------------------
- Generalize in-band control to more diverse network setups
- Bug fixes
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

AC_PREREQ(2.63)
AC_INIT(openvswitch, 0.90.3, [email protected])
AC_INIT(openvswitch, 0.90.5, ovs-[email protected])
NX_BUILDNR
AC_CONFIG_SRCDIR([datapath/datapath.c])
AC_CONFIG_MACRO_DIR([m4])
Expand Down
2 changes: 1 addition & 1 deletion datapath/datapath.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* then this should go into include/linux/if_vlan.h. */
#define VLAN_PCP_MASK 0xe000

#define DP_MAX_PORTS 256
#define DP_MAX_PORTS 1024
#define DP_MAX_GROUPS 16

#define DP_L2_BITS (PAGE_SHIFT - ilog2(sizeof(struct dp_bucket*)))
Expand Down
1 change: 1 addition & 0 deletions lib/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ lib_libopenvswitch_a_SOURCES = \
lib/ofp-print.h \
lib/ofpbuf.c \
lib/ofpbuf.h \
lib/packets.c \
lib/packets.h \
lib/pcap.c \
lib/pcap.h \
Expand Down
2 changes: 1 addition & 1 deletion lib/mac-learning.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define MAC_HASH_MASK (MAC_HASH_SIZE - 1)
#define MAC_HASH_SIZE (1u << MAC_HASH_BITS)

#define MAC_MAX 1024
#define MAC_MAX 2048

/* Time, in seconds, before expiring a mac_entry due to inactivity. */
#define MAC_ENTRY_IDLE_TIME 60
Expand Down
3 changes: 3 additions & 0 deletions lib/netdev-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ get_stats_via_netlink(int ifindex, struct netdev_stats *stats)

if (!attrs[IFLA_STATS]) {
VLOG_WARN_RL(&rl, "RTM_GETLINK reply lacks stats");
ofpbuf_delete(reply);
return EPROTO;
}

Expand All @@ -1522,6 +1523,8 @@ get_stats_via_netlink(int ifindex, struct netdev_stats *stats)
stats->tx_heartbeat_errors = rtnl_stats->tx_heartbeat_errors;
stats->tx_window_errors = rtnl_stats->tx_window_errors;

ofpbuf_delete(reply);

return 0;
}

Expand Down
58 changes: 58 additions & 0 deletions lib/packets.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2009 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <config.h>
#include "packets.h"
#include <netinet/in.h>
#include "ofpbuf.h"

/* Fills 'b' with an 802.2 SNAP packet with Ethernet source address 'eth_src',
* the Nicira OUI as SNAP organization and 'snap_type' as SNAP type. The text
* string in 'tag' is enclosed as the packet payload.
*
* This function is used by Open vSwitch to compose packets in cases where
* context is important but content doesn't (or shouldn't) matter. For this
* purpose, 'snap_type' should be a random number and 'tag' should be an
* English phrase that explains the purpose of the packet. (The English phrase
* gives hapless admins running Wireshark the opportunity to figure out what's
* going on.) */
void
compose_benign_packet(struct ofpbuf *b, const char *tag, uint16_t snap_type,
const uint8_t eth_src[ETH_ADDR_LEN])
{
struct eth_header *eth;
struct llc_snap_header *llc_snap;

/* Compose basic packet structure. (We need the payload size to stick into
* the 802.2 header.) */
ofpbuf_clear(b);
eth = ofpbuf_put_zeros(b, ETH_HEADER_LEN);
llc_snap = ofpbuf_put_zeros(b, LLC_SNAP_HEADER_LEN);
ofpbuf_put(b, tag, strlen(tag) + 1); /* Includes null byte. */
ofpbuf_put(b, eth_src, ETH_ADDR_LEN);

/* Compose 802.2 header. */
memcpy(eth->eth_dst, eth_addr_broadcast, ETH_ADDR_LEN);
memcpy(eth->eth_src, eth_src, ETH_ADDR_LEN);
eth->eth_type = htons(b->size - ETH_HEADER_LEN);

/* Compose LLC, SNAP headers. */
llc_snap->llc.llc_dsap = LLC_DSAP_SNAP;
llc_snap->llc.llc_ssap = LLC_SSAP_SNAP;
llc_snap->llc.llc_cntl = LLC_CNTL_SNAP;
memcpy(llc_snap->snap.snap_org, "\x00\x23\x20", 3);
llc_snap->snap.snap_type = htons(snap_type);
}
7 changes: 7 additions & 0 deletions lib/packets.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef PACKETS_H
#define PACKETS_H 1

Expand All @@ -23,6 +24,8 @@
#include "random.h"
#include "util.h"

struct ofpbuf;

#define ETH_ADDR_LEN 6

static const uint8_t eth_addr_broadcast[ETH_ADDR_LEN] UNUSED
Expand Down Expand Up @@ -98,6 +101,10 @@ static inline bool eth_addr_is_reserved(const uint8_t ea[ETH_ADDR_LEN])
&& (ea[5] & 0xf0) == 0x00);
}

void compose_benign_packet(struct ofpbuf *, const char *tag,
uint16_t snap_type,
const uint8_t eth_src[ETH_ADDR_LEN]);

/* Example:
*
* uint8_t mac[ETH_ADDR_LEN];
Expand Down
21 changes: 14 additions & 7 deletions lib/rconn.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ rconn_recv(struct rconn *rc)
int error = vconn_recv(rc->vconn, &buffer);
if (!error) {
copy_to_monitor(rc, buffer);
if (is_admitted_msg(buffer)
if (rc->probably_admitted || is_admitted_msg(buffer)
|| time_now() - rc->last_connected >= 30) {
rc->probably_admitted = true;
rc->last_admitted = time_now();
Expand Down Expand Up @@ -637,15 +637,22 @@ rconn_is_connected(const struct rconn *rconn)
return is_connected_state(rconn->state);
}

/* Returns 0 if 'rconn' is connected. Otherwise, if 'rconn' is in a "failure
* mode" (that is, it is not connected), returns the number of seconds that it
* has been in failure mode, ignoring any times that it connected but the
* controller's admission control policy caused it to be quickly
* disconnected. */
/* Returns true if 'rconn' is connected and thought to have been accepted by
* the peer's admission-control policy. */
bool
rconn_is_admitted(const struct rconn *rconn)
{
return (rconn_is_connected(rconn)
&& rconn->last_admitted >= rconn->last_connected);
}

/* Returns 0 if 'rconn' is currently connected and considered to have been
* accepted by the peer's admission-control policy, otherwise the number of
* seconds since 'rconn' was last in such a state. */
int
rconn_failure_duration(const struct rconn *rconn)
{
return rconn_is_connected(rconn) ? 0 : time_now() - rconn->last_admitted;
return rconn_is_admitted(rconn) ? 0 : time_now() - rconn->last_admitted;
}

/* Returns the IP address of the peer, or 0 if the peer's IP address is not
Expand Down
1 change: 1 addition & 0 deletions lib/rconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void rconn_add_monitor(struct rconn *, struct vconn *);
const char *rconn_get_name(const struct rconn *);
bool rconn_is_alive(const struct rconn *);
bool rconn_is_connected(const struct rconn *);
bool rconn_is_admitted(const struct rconn *);
int rconn_failure_duration(const struct rconn *);
bool rconn_is_connectivity_questionable(struct rconn *);

Expand Down
22 changes: 22 additions & 0 deletions lib/vconn.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,28 @@ make_add_simple_flow(const flow_t *flow,
return buffer;
}

struct ofpbuf *
make_packet_in(uint32_t buffer_id, uint16_t in_port, uint8_t reason,
const struct ofpbuf *payload, int max_send_len)
{
struct ofp_packet_in *opi;
struct ofpbuf *buf;
int send_len;

send_len = MIN(max_send_len, payload->size);
buf = ofpbuf_new(sizeof *opi + send_len);
opi = put_openflow_xid(offsetof(struct ofp_packet_in, data),
OFPT_PACKET_IN, 0, buf);
opi->buffer_id = htonl(buffer_id);
opi->total_len = htons(payload->size);
opi->in_port = htons(in_port);
opi->reason = reason;
ofpbuf_put(buf, payload->data, send_len);
update_openflow_length(buf);

return buf;
}

struct ofpbuf *
make_packet_out(const struct ofpbuf *packet, uint32_t buffer_id,
uint16_t in_port,
Expand Down
3 changes: 3 additions & 0 deletions lib/vconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ struct ofpbuf *make_del_flow(const flow_t *);
struct ofpbuf *make_add_simple_flow(const flow_t *,
uint32_t buffer_id, uint16_t out_port,
uint16_t max_idle);
struct ofpbuf *make_packet_in(uint32_t buffer_id, uint16_t in_port,
uint8_t reason,
const struct ofpbuf *payload, int max_send_len);
struct ofpbuf *make_packet_out(const struct ofpbuf *packet, uint32_t buffer_id,
uint16_t in_port,
const struct ofp_action_header *,
Expand Down
Loading

0 comments on commit 576e26d

Please sign in to comment.