secchan: Drop redundant 'in_port' args to in-band, fail-open miss handlers.
authorBen Pfaff <blp@nicira.com>
Fri, 13 Mar 2009 23:48:01 +0000 (16:48 -0700)
committerBen Pfaff <blp@nicira.com>
Sat, 14 Mar 2009 00:05:45 +0000 (17:05 -0700)
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
secchan/fail-open.h
secchan/in-band.c
secchan/in-band.h
secchan/ofproto.c

index 1b3e75fd6cf1c409e483718dd1b9a1762532c8f3..4a024f9a47c258278dd873f513d9cf94fc39ca84 100644 (file)
@@ -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) {
index 207a7915338fadfe1dc363e315af906cc7cb877e..96f923501810878145da1b014c1d1b2f808bad14 100644 (file)
@@ -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 */
index 6212061d13241fee6d30b4111fd1db2b979f445e..c3a7c954f83d325b2c1cc6110999082d1599eef5 100644 (file)
@@ -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);
     }
index cc37af144c06c62f28282595fbc1754ca3323909..570f65bf458658b7bbb7bb74b4c0032b8b96b80e 100644 (file)
@@ -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 */
index a4f68b01fd76d3dd21cba8478303935ec518c3cf..2bd2633e10a2f366ce7619e6da6a9c75c63618a7 100644 (file)
@@ -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;
         }