]> git.proxmox.com Git - ovs.git/blob - lib/learning-switch.c
Implement OpenFlow 1.1+ "groups" protocol.
[ovs.git] / lib / learning-switch.c
1 /*
2 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <config.h>
18 #include "learning-switch.h"
19
20 #include <errno.h>
21 #include <inttypes.h>
22 #include <netinet/in.h>
23 #include <stdlib.h>
24 #include <time.h>
25
26 #include "byte-order.h"
27 #include "classifier.h"
28 #include "flow.h"
29 #include "hmap.h"
30 #include "mac-learning.h"
31 #include "ofpbuf.h"
32 #include "ofp-actions.h"
33 #include "ofp-errors.h"
34 #include "ofp-msgs.h"
35 #include "ofp-parse.h"
36 #include "ofp-print.h"
37 #include "ofp-util.h"
38 #include "openflow/openflow.h"
39 #include "poll-loop.h"
40 #include "rconn.h"
41 #include "shash.h"
42 #include "simap.h"
43 #include "timeval.h"
44 #include "vconn.h"
45 #include "vlog.h"
46
47 VLOG_DEFINE_THIS_MODULE(learning_switch);
48
49 struct lswitch_port {
50 struct hmap_node hmap_node; /* Hash node for port number. */
51 ofp_port_t port_no; /* OpenFlow port number. */
52 uint32_t queue_id; /* OpenFlow queue number. */
53 };
54
55 enum lswitch_state {
56 S_CONNECTING, /* Waiting for connection to complete. */
57 S_FEATURES_REPLY, /* Waiting for features reply. */
58 S_SWITCHING, /* Switching flows. */
59 };
60
61 struct lswitch {
62 struct rconn *rconn;
63 enum lswitch_state state;
64
65 /* If nonnegative, the switch sets up flows that expire after the given
66 * number of seconds (or never expire, if the value is OFP_FLOW_PERMANENT).
67 * Otherwise, the switch processes every packet. */
68 int max_idle;
69
70 enum ofputil_protocol protocol;
71 unsigned long long int datapath_id;
72 struct mac_learning *ml; /* NULL to act as hub instead of switch. */
73 struct flow_wildcards wc; /* Wildcards to apply to flows. */
74 bool action_normal; /* Use OFPP_NORMAL? */
75
76 /* Queue distribution. */
77 uint32_t default_queue; /* Default OpenFlow queue, or UINT32_MAX. */
78 struct hmap queue_numbers; /* Map from port number to lswitch_port. */
79 struct shash queue_names; /* Map from port name to lswitch_port. */
80
81 /* Number of outgoing queued packets on the rconn. */
82 struct rconn_packet_counter *queued;
83
84 /* If true, do not reply to any messages from the switch (for debugging
85 * fail-open mode). */
86 bool mute;
87
88 /* Optional "flow mod" requests to send to the switch at connection time,
89 * to set up the flow table. */
90 const struct ofputil_flow_mod *default_flows;
91 size_t n_default_flows;
92 enum ofputil_protocol usable_protocols;
93 };
94
95 /* The log messages here could actually be useful in debugging, so keep the
96 * rate limit relatively high. */
97 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(30, 300);
98
99 static void queue_tx(struct lswitch *, struct ofpbuf *);
100 static void send_features_request(struct lswitch *);
101
102 static void lswitch_process_packet(struct lswitch *, const struct ofpbuf *);
103 static enum ofperr process_switch_features(struct lswitch *,
104 struct ofp_header *);
105 static void process_packet_in(struct lswitch *, const struct ofp_header *);
106 static void process_echo_request(struct lswitch *, const struct ofp_header *);
107
108 /* Creates and returns a new learning switch whose configuration is given by
109 * 'cfg'.
110 *
111 * 'rconn' is used to send out an OpenFlow features request. */
112 struct lswitch *
113 lswitch_create(struct rconn *rconn, const struct lswitch_config *cfg)
114 {
115 struct lswitch *sw;
116 uint32_t ofpfw;
117
118 sw = xzalloc(sizeof *sw);
119 sw->rconn = rconn;
120 sw->state = S_CONNECTING;
121 sw->max_idle = cfg->max_idle;
122 sw->datapath_id = 0;
123 sw->ml = (cfg->mode == LSW_LEARN
124 ? mac_learning_create(MAC_ENTRY_DEFAULT_IDLE_TIME)
125 : NULL);
126 sw->action_normal = cfg->mode == LSW_NORMAL;
127
128 switch (cfg->wildcards) {
129 case 0:
130 ofpfw = 0;
131 break;
132
133 case UINT32_MAX:
134 /* Try to wildcard as many fields as possible, but we cannot
135 * wildcard all fields. We need in_port to detect moves. We need
136 * Ethernet source and dest and VLAN VID to do L2 learning. */
137 ofpfw = (OFPFW10_DL_TYPE | OFPFW10_DL_VLAN_PCP
138 | OFPFW10_NW_SRC_ALL | OFPFW10_NW_DST_ALL
139 | OFPFW10_NW_TOS | OFPFW10_NW_PROTO
140 | OFPFW10_TP_SRC | OFPFW10_TP_DST);
141 break;
142
143 default:
144 ofpfw = cfg->wildcards;
145 break;
146 }
147 ofputil_wildcard_from_ofpfw10(ofpfw, &sw->wc);
148
149 sw->default_queue = cfg->default_queue;
150 hmap_init(&sw->queue_numbers);
151 shash_init(&sw->queue_names);
152 if (cfg->port_queues) {
153 struct simap_node *node;
154
155 SIMAP_FOR_EACH (node, cfg->port_queues) {
156 struct lswitch_port *port = xmalloc(sizeof *port);
157 hmap_node_nullify(&port->hmap_node);
158 port->queue_id = node->data;
159 shash_add(&sw->queue_names, node->name, port);
160 }
161 }
162
163 sw->default_flows = cfg->default_flows;
164 sw->n_default_flows = cfg->n_default_flows;
165 sw->usable_protocols = cfg->usable_protocols;
166
167 sw->queued = rconn_packet_counter_create();
168
169 return sw;
170 }
171
172 static void
173 lswitch_handshake(struct lswitch *sw)
174 {
175 enum ofputil_protocol protocol;
176
177 send_features_request(sw);
178
179 protocol = ofputil_protocol_from_ofp_version(rconn_get_version(sw->rconn));
180 if (sw->default_flows) {
181 struct ofpbuf *msg = NULL;
182 int error = 0;
183 size_t i;
184
185 /* If the initial protocol isn't good enough for default_flows, then
186 * pick one that will work and encode messages to set up that
187 * protocol.
188 *
189 * This could be improved by actually negotiating a mutually acceptable
190 * flow format with the switch, but that would require an asynchronous
191 * state machine. This version ought to work fine in practice. */
192 if (!(protocol & sw->usable_protocols)) {
193 enum ofputil_protocol want = rightmost_1bit(sw->usable_protocols);
194 while (!error) {
195 msg = ofputil_encode_set_protocol(protocol, want, &protocol);
196 if (!msg) {
197 break;
198 }
199 error = rconn_send(sw->rconn, msg, NULL);
200 }
201 }
202 if (protocol & sw->usable_protocols) {
203 for (i = 0; !error && i < sw->n_default_flows; i++) {
204 msg = ofputil_encode_flow_mod(&sw->default_flows[i], protocol);
205 error = rconn_send(sw->rconn, msg, NULL);
206 }
207
208 if (error) {
209 VLOG_INFO_RL(&rl, "%s: failed to queue default flows (%s)",
210 rconn_get_name(sw->rconn), ovs_strerror(error));
211 }
212 } else {
213 VLOG_INFO_RL(&rl, "%s: failed to set usable protocol",
214 rconn_get_name(sw->rconn));
215 }
216 }
217 sw->protocol = protocol;
218 }
219
220 bool
221 lswitch_is_alive(const struct lswitch *sw)
222 {
223 return rconn_is_alive(sw->rconn);
224 }
225
226 /* Destroys 'sw'. */
227 void
228 lswitch_destroy(struct lswitch *sw)
229 {
230 if (sw) {
231 struct lswitch_port *node, *next;
232
233 rconn_destroy(sw->rconn);
234 HMAP_FOR_EACH_SAFE (node, next, hmap_node, &sw->queue_numbers) {
235 hmap_remove(&sw->queue_numbers, &node->hmap_node);
236 free(node);
237 }
238 shash_destroy(&sw->queue_names);
239 mac_learning_unref(sw->ml);
240 rconn_packet_counter_destroy(sw->queued);
241 free(sw);
242 }
243 }
244
245 /* Takes care of necessary 'sw' activity, except for receiving packets (which
246 * the caller must do). */
247 void
248 lswitch_run(struct lswitch *sw)
249 {
250 int i;
251
252 if (sw->ml) {
253 ovs_rwlock_wrlock(&sw->ml->rwlock);
254 mac_learning_run(sw->ml);
255 ovs_rwlock_unlock(&sw->ml->rwlock);
256 }
257
258 rconn_run(sw->rconn);
259
260 if (sw->state == S_CONNECTING) {
261 if (rconn_get_version(sw->rconn) != -1) {
262 lswitch_handshake(sw);
263 sw->state = S_FEATURES_REPLY;
264 }
265 return;
266 }
267
268 for (i = 0; i < 50; i++) {
269 struct ofpbuf *msg;
270
271 msg = rconn_recv(sw->rconn);
272 if (!msg) {
273 break;
274 }
275
276 if (!sw->mute) {
277 lswitch_process_packet(sw, msg);
278 }
279 ofpbuf_delete(msg);
280 }
281 }
282
283 void
284 lswitch_wait(struct lswitch *sw)
285 {
286 if (sw->ml) {
287 ovs_rwlock_rdlock(&sw->ml->rwlock);
288 mac_learning_wait(sw->ml);
289 ovs_rwlock_unlock(&sw->ml->rwlock);
290 }
291 rconn_run_wait(sw->rconn);
292 rconn_recv_wait(sw->rconn);
293 }
294
295 /* Processes 'msg', which should be an OpenFlow received on 'rconn', according
296 * to the learning switch state in 'sw'. The most likely result of processing
297 * is that flow-setup and packet-out OpenFlow messages will be sent out on
298 * 'rconn'. */
299 static void
300 lswitch_process_packet(struct lswitch *sw, const struct ofpbuf *msg)
301 {
302 enum ofptype type;
303 struct ofpbuf b;
304
305 b = *msg;
306 if (ofptype_pull(&type, &b)) {
307 return;
308 }
309
310 if (sw->state == S_FEATURES_REPLY
311 && type != OFPTYPE_ECHO_REQUEST
312 && type != OFPTYPE_FEATURES_REPLY) {
313 return;
314 }
315
316 switch (type) {
317 case OFPTYPE_ECHO_REQUEST:
318 process_echo_request(sw, msg->data);
319 break;
320
321 case OFPTYPE_FEATURES_REPLY:
322 if (sw->state == S_FEATURES_REPLY) {
323 if (!process_switch_features(sw, msg->data)) {
324 sw->state = S_SWITCHING;
325 } else {
326 rconn_disconnect(sw->rconn);
327 }
328 }
329 break;
330
331 case OFPTYPE_PACKET_IN:
332 process_packet_in(sw, msg->data);
333 break;
334
335 case OFPTYPE_FLOW_REMOVED:
336 /* Nothing to do. */
337 break;
338
339 case OFPTYPE_HELLO:
340 case OFPTYPE_ERROR:
341 case OFPTYPE_ECHO_REPLY:
342 case OFPTYPE_FEATURES_REQUEST:
343 case OFPTYPE_GET_CONFIG_REQUEST:
344 case OFPTYPE_GET_CONFIG_REPLY:
345 case OFPTYPE_SET_CONFIG:
346 case OFPTYPE_PORT_STATUS:
347 case OFPTYPE_PACKET_OUT:
348 case OFPTYPE_FLOW_MOD:
349 case OFPTYPE_GROUP_MOD:
350 case OFPTYPE_PORT_MOD:
351 case OFPTYPE_BARRIER_REQUEST:
352 case OFPTYPE_BARRIER_REPLY:
353 case OFPTYPE_QUEUE_GET_CONFIG_REQUEST:
354 case OFPTYPE_QUEUE_GET_CONFIG_REPLY:
355 case OFPTYPE_DESC_STATS_REQUEST:
356 case OFPTYPE_DESC_STATS_REPLY:
357 case OFPTYPE_FLOW_STATS_REQUEST:
358 case OFPTYPE_FLOW_STATS_REPLY:
359 case OFPTYPE_AGGREGATE_STATS_REQUEST:
360 case OFPTYPE_AGGREGATE_STATS_REPLY:
361 case OFPTYPE_TABLE_STATS_REQUEST:
362 case OFPTYPE_TABLE_STATS_REPLY:
363 case OFPTYPE_PORT_STATS_REQUEST:
364 case OFPTYPE_PORT_STATS_REPLY:
365 case OFPTYPE_QUEUE_STATS_REQUEST:
366 case OFPTYPE_QUEUE_STATS_REPLY:
367 case OFPTYPE_PORT_DESC_STATS_REQUEST:
368 case OFPTYPE_PORT_DESC_STATS_REPLY:
369 case OFPTYPE_ROLE_REQUEST:
370 case OFPTYPE_ROLE_REPLY:
371 case OFPTYPE_SET_FLOW_FORMAT:
372 case OFPTYPE_FLOW_MOD_TABLE_ID:
373 case OFPTYPE_SET_PACKET_IN_FORMAT:
374 case OFPTYPE_FLOW_AGE:
375 case OFPTYPE_SET_CONTROLLER_ID:
376 case OFPTYPE_FLOW_MONITOR_STATS_REQUEST:
377 case OFPTYPE_FLOW_MONITOR_STATS_REPLY:
378 case OFPTYPE_FLOW_MONITOR_CANCEL:
379 case OFPTYPE_FLOW_MONITOR_PAUSED:
380 case OFPTYPE_FLOW_MONITOR_RESUMED:
381 case OFPTYPE_GET_ASYNC_REQUEST:
382 case OFPTYPE_GET_ASYNC_REPLY:
383 case OFPTYPE_SET_ASYNC_CONFIG:
384 case OFPTYPE_METER_MOD:
385 case OFPTYPE_GROUP_STATS_REQUEST:
386 case OFPTYPE_GROUP_STATS_REPLY:
387 case OFPTYPE_GROUP_DESC_STATS_REQUEST:
388 case OFPTYPE_GROUP_DESC_STATS_REPLY:
389 case OFPTYPE_GROUP_FEATURES_STATS_REQUEST:
390 case OFPTYPE_GROUP_FEATURES_STATS_REPLY:
391 case OFPTYPE_METER_STATS_REQUEST:
392 case OFPTYPE_METER_STATS_REPLY:
393 case OFPTYPE_METER_CONFIG_STATS_REQUEST:
394 case OFPTYPE_METER_CONFIG_STATS_REPLY:
395 case OFPTYPE_METER_FEATURES_STATS_REQUEST:
396 case OFPTYPE_METER_FEATURES_STATS_REPLY:
397 case OFPTYPE_TABLE_FEATURES_STATS_REQUEST:
398 case OFPTYPE_TABLE_FEATURES_STATS_REPLY:
399 default:
400 if (VLOG_IS_DBG_ENABLED()) {
401 char *s = ofp_to_string(msg->data, msg->size, 2);
402 VLOG_DBG_RL(&rl, "%016llx: OpenFlow packet ignored: %s",
403 sw->datapath_id, s);
404 free(s);
405 }
406 }
407 }
408 \f
409 static void
410 send_features_request(struct lswitch *sw)
411 {
412 struct ofpbuf *b;
413 struct ofp_switch_config *osc;
414 int ofp_version = rconn_get_version(sw->rconn);
415
416 ovs_assert(ofp_version > 0 && ofp_version < 0xff);
417
418 /* Send OFPT_FEATURES_REQUEST. */
419 b = ofpraw_alloc(OFPRAW_OFPT_FEATURES_REQUEST, ofp_version, 0);
420 queue_tx(sw, b);
421
422 /* Send OFPT_SET_CONFIG. */
423 b = ofpraw_alloc(OFPRAW_OFPT_SET_CONFIG, ofp_version, sizeof *osc);
424 osc = ofpbuf_put_zeros(b, sizeof *osc);
425 osc->miss_send_len = htons(OFP_DEFAULT_MISS_SEND_LEN);
426 queue_tx(sw, b);
427 }
428
429 static void
430 queue_tx(struct lswitch *sw, struct ofpbuf *b)
431 {
432 int retval = rconn_send_with_limit(sw->rconn, b, sw->queued, 10);
433 if (retval && retval != ENOTCONN) {
434 if (retval == EAGAIN) {
435 VLOG_INFO_RL(&rl, "%016llx: %s: tx queue overflow",
436 sw->datapath_id, rconn_get_name(sw->rconn));
437 } else {
438 VLOG_WARN_RL(&rl, "%016llx: %s: send: %s",
439 sw->datapath_id, rconn_get_name(sw->rconn),
440 ovs_strerror(retval));
441 }
442 }
443 }
444
445 static enum ofperr
446 process_switch_features(struct lswitch *sw, struct ofp_header *oh)
447 {
448 struct ofputil_switch_features features;
449 struct ofputil_phy_port port;
450 enum ofperr error;
451 struct ofpbuf b;
452
453 error = ofputil_decode_switch_features(oh, &features, &b);
454 if (error) {
455 VLOG_ERR("received invalid switch feature reply (%s)",
456 ofperr_to_string(error));
457 return error;
458 }
459
460 sw->datapath_id = features.datapath_id;
461
462 while (!ofputil_pull_phy_port(oh->version, &b, &port)) {
463 struct lswitch_port *lp = shash_find_data(&sw->queue_names, port.name);
464 if (lp && hmap_node_is_null(&lp->hmap_node)) {
465 lp->port_no = port.port_no;
466 hmap_insert(&sw->queue_numbers, &lp->hmap_node,
467 hash_ofp_port(lp->port_no));
468 }
469 }
470 return 0;
471 }
472
473 static ofp_port_t
474 lswitch_choose_destination(struct lswitch *sw, const struct flow *flow)
475 {
476 ofp_port_t out_port;
477
478 /* Learn the source MAC. */
479 ovs_rwlock_wrlock(&sw->ml->rwlock);
480 if (mac_learning_may_learn(sw->ml, flow->dl_src, 0)) {
481 struct mac_entry *mac = mac_learning_insert(sw->ml, flow->dl_src, 0);
482 if (mac->port.ofp_port != flow->in_port.ofp_port) {
483 VLOG_DBG_RL(&rl, "%016llx: learned that "ETH_ADDR_FMT" is on "
484 "port %"PRIu16, sw->datapath_id,
485 ETH_ADDR_ARGS(flow->dl_src), flow->in_port.ofp_port);
486
487 mac->port.ofp_port = flow->in_port.ofp_port;
488 mac_learning_changed(sw->ml);
489 }
490 }
491 ovs_rwlock_unlock(&sw->ml->rwlock);
492
493 /* Drop frames for reserved multicast addresses. */
494 if (eth_addr_is_reserved(flow->dl_dst)) {
495 return OFPP_NONE;
496 }
497
498 out_port = OFPP_FLOOD;
499 if (sw->ml) {
500 struct mac_entry *mac;
501
502 ovs_rwlock_rdlock(&sw->ml->rwlock);
503 mac = mac_learning_lookup(sw->ml, flow->dl_dst, 0);
504 if (mac) {
505 out_port = mac->port.ofp_port;
506 if (out_port == flow->in_port.ofp_port) {
507 /* Don't send a packet back out its input port. */
508 ovs_rwlock_unlock(&sw->ml->rwlock);
509 return OFPP_NONE;
510 }
511 }
512 ovs_rwlock_unlock(&sw->ml->rwlock);
513 }
514
515 /* Check if we need to use "NORMAL" action. */
516 if (sw->action_normal && out_port != OFPP_FLOOD) {
517 return OFPP_NORMAL;
518 }
519
520 return out_port;
521 }
522
523 static uint32_t
524 get_queue_id(const struct lswitch *sw, ofp_port_t in_port)
525 {
526 const struct lswitch_port *port;
527
528 HMAP_FOR_EACH_WITH_HASH (port, hmap_node, hash_ofp_port(in_port),
529 &sw->queue_numbers) {
530 if (port->port_no == in_port) {
531 return port->queue_id;
532 }
533 }
534
535 return sw->default_queue;
536 }
537
538 static void
539 process_packet_in(struct lswitch *sw, const struct ofp_header *oh)
540 {
541 struct ofputil_packet_in pi;
542 uint32_t queue_id;
543 ofp_port_t out_port;
544
545 uint64_t ofpacts_stub[64 / 8];
546 struct ofpbuf ofpacts;
547
548 struct ofputil_packet_out po;
549 enum ofperr error;
550
551 struct ofpbuf pkt;
552 struct flow flow;
553 union flow_in_port in_port_;
554
555 error = ofputil_decode_packet_in(&pi, oh);
556 if (error) {
557 VLOG_WARN_RL(&rl, "failed to decode packet-in: %s",
558 ofperr_to_string(error));
559 return;
560 }
561
562 /* Ignore packets sent via output to OFPP_CONTROLLER. This library never
563 * uses such an action. You never know what experiments might be going on,
564 * though, and it seems best not to interfere with them. */
565 if (pi.reason != OFPR_NO_MATCH) {
566 return;
567 }
568
569 /* Extract flow data from 'opi' into 'flow'. */
570 ofpbuf_use_const(&pkt, pi.packet, pi.packet_len);
571 in_port_.ofp_port = pi.fmd.in_port;
572 flow_extract(&pkt, 0, 0, NULL, &in_port_, &flow);
573 flow.tunnel.tun_id = pi.fmd.tun_id;
574
575 /* Choose output port. */
576 out_port = lswitch_choose_destination(sw, &flow);
577
578 /* Make actions. */
579 queue_id = get_queue_id(sw, pi.fmd.in_port);
580 ofpbuf_use_stack(&ofpacts, ofpacts_stub, sizeof ofpacts_stub);
581 if (out_port == OFPP_NONE) {
582 /* No actions. */
583 } else if (queue_id == UINT32_MAX
584 || ofp_to_u16(out_port) >= ofp_to_u16(OFPP_MAX)) {
585 ofpact_put_OUTPUT(&ofpacts)->port = out_port;
586 } else {
587 struct ofpact_enqueue *enqueue = ofpact_put_ENQUEUE(&ofpacts);
588 enqueue->port = out_port;
589 enqueue->queue = queue_id;
590 }
591 ofpact_pad(&ofpacts);
592
593 /* Prepare packet_out in case we need one. */
594 po.buffer_id = pi.buffer_id;
595 if (po.buffer_id == UINT32_MAX) {
596 po.packet = pkt.data;
597 po.packet_len = pkt.size;
598 } else {
599 po.packet = NULL;
600 po.packet_len = 0;
601 }
602 po.in_port = pi.fmd.in_port;
603 po.ofpacts = ofpacts.data;
604 po.ofpacts_len = ofpacts.size;
605
606 /* Send the packet, and possibly the whole flow, to the output port. */
607 if (sw->max_idle >= 0 && (!sw->ml || out_port != OFPP_FLOOD)) {
608 struct ofputil_flow_mod fm;
609 struct ofpbuf *buffer;
610
611 /* The output port is known, or we always flood everything, so add a
612 * new flow. */
613 memset(&fm, 0, sizeof fm);
614 match_init(&fm.match, &flow, &sw->wc);
615 ofputil_normalize_match_quiet(&fm.match);
616 fm.priority = 0;
617 fm.table_id = 0xff;
618 fm.command = OFPFC_ADD;
619 fm.idle_timeout = sw->max_idle;
620 fm.buffer_id = pi.buffer_id;
621 fm.out_port = OFPP_NONE;
622 fm.ofpacts = ofpacts.data;
623 fm.ofpacts_len = ofpacts.size;
624 buffer = ofputil_encode_flow_mod(&fm, sw->protocol);
625
626 queue_tx(sw, buffer);
627
628 /* If the switch didn't buffer the packet, we need to send a copy. */
629 if (pi.buffer_id == UINT32_MAX && out_port != OFPP_NONE) {
630 queue_tx(sw, ofputil_encode_packet_out(&po, sw->protocol));
631 }
632 } else {
633 /* We don't know that MAC, or we don't set up flows. Send along the
634 * packet without setting up a flow. */
635 if (pi.buffer_id != UINT32_MAX || out_port != OFPP_NONE) {
636 queue_tx(sw, ofputil_encode_packet_out(&po, sw->protocol));
637 }
638 }
639 }
640
641 static void
642 process_echo_request(struct lswitch *sw, const struct ofp_header *rq)
643 {
644 queue_tx(sw, make_echo_reply(rq));
645 }