From 1e072c81676c8fbc38cb39f3dfec68d7c0e1e791 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 2 Mar 2009 14:13:36 -0800 Subject: [PATCH] vswitchd: Fix bad assumption about byte order of flow_t's "in_port". In the big restructuring of secchan and the datapath, the "in_port" member was changed from network byte order to host byte order, but vswitchd hadn't quite caught up. This fixes the problem. With this commit, at least the most basic use of vswitchd now works again. --- vswitchd/bridge.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 03cd0167..3bd7d252 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -1444,7 +1444,7 @@ compose_dsts(const struct bridge *br, const flow_t *flow, uint16_t vlan, if (port->vlan < 0) { dst->vlan = m->out_vlan; } - if (dst->dp_ifidx == ntohs(flow->in_port)) { + if (dst->dp_ifidx == flow->in_port) { if (dst->vlan == vlan) { /* Don't send out input port on same VLAN. */ continue; @@ -1578,7 +1578,6 @@ static void process_flow(struct bridge *br, const flow_t *flow, struct received_packet *pkt) { - uint16_t in_ifidx = ntohs(flow->in_port); struct iface *in_iface; struct port *in_port; struct port *out_port = NULL; /* By default, drop the packet/flow. */ @@ -1586,7 +1585,7 @@ process_flow(struct bridge *br, const flow_t *flow, int vlan; /* Find the interface and port structure for the received packet. */ - in_iface = iface_from_dp_ifidx(br, in_ifidx); + in_iface = iface_from_dp_ifidx(br, flow->in_port); if (!in_iface) { /* No interface? Something fishy... */ struct ft_flow *f = ft_lookup(br->ft, flow, flow_hash(flow, 0)); @@ -1604,7 +1603,7 @@ process_flow(struct bridge *br, const flow_t *flow, */ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); VLOG_WARN_RL(&rl, "bridge %s: received packet on unknown " - "interface %"PRIu16, br->name, in_ifidx); + "interface %"PRIu16, br->name, flow->in_port); queue_tx(br, make_add_flow(flow, pkt->buffer_id, bridge_idle_time(br), 0)); @@ -1806,7 +1805,7 @@ process_packet_in(struct bridge *br, void *opi_) buf.data = opi->data; pkt.buf = &buf; pkt.buffer_id = ntohl(opi->buffer_id); - flow_extract(&buf, ntohs(opi->in_port), &flow); /* XXX port number translation */ + flow_extract(&buf, ntohs(opi->in_port), &flow); if (opi->reason == OFPR_NO_MATCH) { /* Delete any existing flow from the flow table. It must not really be @@ -3075,14 +3074,12 @@ brstp_receive(struct bridge *br, const flow_t *flow, const struct ofpbuf *pkt) struct eth_header *eth; struct llc_header *llc; struct stp_port *sp; - int in_ifidx; /* Find the interface and port structure for the received packet. */ - in_ifidx = ntohs(flow->in_port); - if (in_ifidx >= STP_MAX_PORTS) { + if (flow->in_port >= STP_MAX_PORTS) { return; } - sp = stp_get_port(br->stp, in_ifidx); + sp = stp_get_port(br->stp, flow->in_port); if (stp_port_get_state(sp) == STP_DISABLED) { return; } @@ -3101,7 +3098,7 @@ brstp_receive(struct bridge *br, const flow_t *flow, const struct ofpbuf *pkt) payload.size = ntohs(eth->eth_type) + ETH_HEADER_LEN; } if (ofpbuf_try_pull(&payload, ETH_HEADER_LEN + LLC_HEADER_LEN)) { - struct stp_port *p = stp_get_port(br->stp, ntohs(flow->in_port)); + struct stp_port *p = stp_get_port(br->stp, flow->in_port); stp_received_bpdu(p, payload.data, payload.size); } } -- 2.30.2