From 4df84872197addec1d26e7bc8b4b04a2fbcbc441 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 13 Mar 2009 16:48:01 -0700 Subject: [PATCH] secchan: Drop redundant 'in_port' args to in-band, fail-open miss handlers. The in_band_handle_flow_miss() and fail_open_handle_flow_miss() functions have 'in_port' arguments that are completely redundant with their 'flow' arguments' 'in_port' members. Drop the 'in_port' parameters. --- secchan/fail-open.c | 9 ++++----- secchan/fail-open.h | 3 +-- secchan/in-band.c | 16 +++++++--------- secchan/in-band.h | 3 +-- secchan/ofproto.c | 5 ++--- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/secchan/fail-open.c b/secchan/fail-open.c index 1b3e75fd..4a024f9a 100644 --- a/secchan/fail-open.c +++ b/secchan/fail-open.c @@ -90,8 +90,7 @@ fail_open_wait(struct fail_open *fo) bool fail_open_handle_flow_miss(struct fail_open *fo, struct ofproto *ofproto, - uint16_t in_port, const flow_t *flow, - const struct ofpbuf *payload) + const flow_t *flow, const struct ofpbuf *payload) { /* -1 (FLOOD) is coincidentally the value returned by mac_learning_lookup() * when it doesn't have a entry for that address. */ @@ -103,10 +102,10 @@ fail_open_handle_flow_miss(struct fail_open *fo, struct ofproto *ofproto, return false; } - if (mac_learning_learn(fo->mac_learning, flow->dl_src, 0, in_port)) { + if (mac_learning_learn(fo->mac_learning, flow->dl_src, 0, flow->in_port)) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(30, 300); VLOG_DBG_RL(&rl, "learned that "ETH_ADDR_FMT" is on port %"PRIu16, - ETH_ADDR_ARGS(flow->dl_src), in_port); + ETH_ADDR_ARGS(flow->dl_src), flow->in_port); } out_port = (eth_addr_is_reserved(flow->dl_src) ? DROP @@ -114,7 +113,7 @@ fail_open_handle_flow_miss(struct fail_open *fo, struct ofproto *ofproto, memset(&action, 0, sizeof action); action.output.type = htons(OFPAT_OUTPUT); action.output.len = htons(sizeof action); - if (in_port == out_port || out_port == DROP) { + if (flow->in_port == out_port || out_port == DROP) { /* Set up a flow to drop packets. */ ofproto_add_flow(ofproto, flow, 0, UINT16_MAX, NULL, 0, NULL, -1); } else if (out_port != FLOOD) { diff --git a/secchan/fail-open.h b/secchan/fail-open.h index 207a7915..96f92350 100644 --- a/secchan/fail-open.h +++ b/secchan/fail-open.h @@ -51,7 +51,6 @@ void fail_open_destroy(struct fail_open *); void fail_open_wait(struct fail_open *); void fail_open_run(struct fail_open *); bool fail_open_handle_flow_miss(struct fail_open *, struct ofproto *, - uint16_t in_port, const flow_t *, - const struct ofpbuf *payload); + const flow_t *, const struct ofpbuf *payload); #endif /* fail-open.h */ diff --git a/secchan/in-band.c b/secchan/in-band.c index 6212061d..c3a7c954 100644 --- a/secchan/in-band.c +++ b/secchan/in-band.c @@ -133,8 +133,7 @@ in_band_learn_mac(struct in_band *in_band, bool in_band_handle_flow_miss(struct in_band *in_band, struct ofproto *ofproto, - uint16_t in_port, const flow_t *flow, - const struct ofpbuf *payload) + const flow_t *flow, const struct ofpbuf *payload) { /* -1 (FLOOD) is coincidentally the value returned by mac_learning_lookup() * when it doesn't have a entry for that address. */ @@ -143,14 +142,14 @@ in_band_handle_flow_miss(struct in_band *in_band, struct ofproto *ofproto, int out_port; /* Deal with local stuff. */ - if (in_port == ODPP_LOCAL) { + if (flow->in_port == ODPP_LOCAL) { /* Sent by secure channel. */ out_port = mac_learning_lookup(in_band->mac_learning, flow->dl_dst, 0); } else if (eth_addr_equals(flow->dl_dst, netdev_get_etheraddr(in_band->netdev))) { /* Sent to secure channel. */ out_port = ODPP_LOCAL; - in_band_learn_mac(in_band, in_port, flow->dl_src); + in_band_learn_mac(in_band, flow->in_port, flow->dl_src); } else if (flow->dl_type == htons(ETH_TYPE_ARP) && eth_addr_is_broadcast(flow->dl_dst) && is_controller_mac(flow->dl_src, in_band)) { @@ -165,7 +164,7 @@ in_band_handle_flow_miss(struct in_band *in_band, struct ofproto *ofproto, flow->tp_dst == htons(OFP_TCP_PORT) || flow->tp_dst == htons(OFP_SSL_PORT))) { /* Traffic to or from controller. Switch it by hand. */ - in_band_learn_mac(in_band, in_port, flow->dl_src); + in_band_learn_mac(in_band, flow->in_port, flow->dl_src); out_port = mac_learning_lookup(in_band->mac_learning, flow->dl_dst, 0); } else { const uint8_t *controller_mac = get_controller_mac(in_band); @@ -175,8 +174,8 @@ in_band_handle_flow_miss(struct in_band *in_band, struct ofproto *ofproto, /* ARP sent by controller. */ out_port = FLOOD; } else if (is_controller_mac(flow->dl_dst, in_band) - && in_port == mac_learning_lookup(in_band->mac_learning, - controller_mac, 0)) { + && flow->in_port == mac_learning_lookup( + in_band->mac_learning, controller_mac, 0)) { /* Drop controller traffic that arrives on the controller port. */ out_port = DROP; } else { @@ -187,7 +186,7 @@ in_band_handle_flow_miss(struct in_band *in_band, struct ofproto *ofproto, memset(&action, 0, sizeof action); action.output.type = htons(OFPAT_OUTPUT); action.output.len = htons(sizeof action); - if (in_port == out_port || out_port == DROP) { + if (flow->in_port == out_port || out_port == DROP) { /* Set up a flow to drop packets. */ ofproto_add_flow(ofproto, flow, 0, UINT16_MAX, NULL, 0, NULL, -1); } else if (out_port != FLOOD) { @@ -198,7 +197,6 @@ in_band_handle_flow_miss(struct in_band *in_band, struct ofproto *ofproto, } else { /* We don't know that MAC. Send along the packet without setting up a * flow. */ - action.type = htons(OFPAT_OUTPUT); action.output.port = htons(OFPP_FLOOD); ofproto_send_packet(ofproto, flow, &action, 1, payload); } diff --git a/secchan/in-band.h b/secchan/in-band.h index cc37af14..570f65bf 100644 --- a/secchan/in-band.h +++ b/secchan/in-band.h @@ -50,7 +50,6 @@ void in_band_destroy(struct in_band *); void in_band_run(struct in_band *); void in_band_wait(struct in_band *); bool in_band_handle_flow_miss(struct in_band *, struct ofproto *, - uint16_t in_port, const flow_t *, - const struct ofpbuf *payload); + const flow_t *, const struct ofpbuf *payload); #endif /* in-band.h */ diff --git a/secchan/ofproto.c b/secchan/ofproto.c index a4f68b01..2bd2633e 100644 --- a/secchan/ofproto.c +++ b/secchan/ofproto.c @@ -2578,15 +2578,14 @@ handle_odp_msg(struct ofproto *p, struct ofpbuf *packet) if (!rule) { struct ofport *port; - if (p->in_band && in_band_handle_flow_miss(p->in_band, p, msg->port, + if (p->in_band && in_band_handle_flow_miss(p->in_band, p, &flow, &payload)) { ofpbuf_delete(packet); return; } if (p->fail_open && fail_open_handle_flow_miss(p->fail_open, p, - msg->port, &flow, - &payload)) { + &flow, &payload)) { ofpbuf_delete(packet); return; } -- 2.30.2