OK, sure
> On 14.10.2016, at 14:26, Rafael Zalamena <[email protected]> wrote:
>
> The switch(4) packet_out handler wasn't handling some cases, so here is
> the missing code.
>
> 1) pout_buffer_id is a 4 bytes field and it was using the wrong define
> to check for absence of buffers;
> 2) When a buffer_id was sent the code didn't handle this, now when this
> happens we send an error message back;
> 3) Call the classifier function again for packet_out otherwise the
> *_set_field* action functions will panic();
>
> ok?
>
> Index: net/if_switch.c
> ===================================================================
> RCS file: /home/obsdcvs/src/sys/net/if_switch.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 if_switch.c
> --- net/if_switch.c 8 Oct 2016 23:36:10 -0000 1.9
> +++ net/if_switch.c 13 Oct 2016 16:08:28 -0000
> @@ -124,9 +124,6 @@ struct mbuf
> struct mbuf
> *switch_flow_classifier_tunnel(struct mbuf *, int *,
> struct switch_flow_classify *);
> -struct mbuf
> - *switch_flow_classifier(struct mbuf *, uint32_t,
> - struct switch_flow_classify *);
> void switch_flow_classifier_dump(struct switch_softc *,
> struct switch_flow_classify *);
> void switchattach(int);
> Index: net/if_switch.h
> ===================================================================
> RCS file: /home/obsdcvs/src/sys/net/if_switch.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 if_switch.h
> --- net/if_switch.h 7 Oct 2016 08:18:22 -0000 1.4
> +++ net/if_switch.h 13 Oct 2016 16:08:49 -0000
> @@ -216,6 +216,9 @@ void switch_port_egress(struct switch_s
> int switch_swfcl_dup(struct switch_flow_classify *,
> struct switch_flow_classify *);
> void switch_swfcl_free(struct switch_flow_classify *);
> +struct mbuf
> + *switch_flow_classifier(struct mbuf *, uint32_t,
> + struct switch_flow_classify *);
>
> /* switchctl.c */
> void switch_dev_destroy(struct switch_softc *);
> Index: net/switchofp.c
> ===================================================================
> RCS file: /home/obsdcvs/src/sys/net/switchofp.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 switchofp.c
> --- net/switchofp.c 12 Oct 2016 09:50:55 -0000 1.13
> +++ net/switchofp.c 14 Oct 2016 10:22:53 -0000
> @@ -5080,7 +5080,7 @@ swofp_recv_packet_out(struct switch_soft
> pout = mtod(m, struct ofp_packet_out *);
>
> al_start = offsetof(struct ofp_packet_out, pout_actions);
> - if (pout->pout_buffer_id != OFP_CONTROLLER_MAXLEN_NO_BUFFER) {
> + if (pout->pout_buffer_id == OFP_PKTOUT_NO_BUFFER) {
> /*
> * It's not necessary to deep copy at here because it's done
> * in m_dup_pkt().
> @@ -5098,6 +5098,17 @@ swofp_recv_packet_out(struct switch_soft
> }
>
> mc = mcn;
> + } else {
> + /* TODO We don't do buffering yet. */
> + swofp_send_error(sc, m, OFP_ERRTYPE_BAD_REQUEST,
> + OFP_ERRREQ_BUFFER_UNKNOWN);
> + return (0);
> + }
> +
> + mc = switch_flow_classifier(mc, pout->pout_in_port, &swfcl);
> + if (mc == NULL) {
> + m_freem(m);
> + return (0);
> }
>
> TAILQ_INIT(&swpld.swpld_fwdp_q);
>