From 61254e479b484bc0410a790688dcc7ac828a8b8f Mon Sep 17 00:00:00 2001 From: reyk Date: Thu, 21 Jul 2016 08:39:23 +0000 Subject: [PATCH] With uint32_t ports, we cannot sneak the port into an int anymore --- usr.sbin/switchd/ofp10.c | 6 +++--- usr.sbin/switchd/packet.c | 15 +++++++++------ usr.sbin/switchd/switchd.h | 7 ++++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/usr.sbin/switchd/ofp10.c b/usr.sbin/switchd/ofp10.c index 5d9657ec8e3..c12a326ec43 100644 --- a/usr.sbin/switchd/ofp10.c +++ b/usr.sbin/switchd/ofp10.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofp10.c,v 1.4 2016/07/21 07:58:44 reyk Exp $ */ +/* $OpenBSD: ofp10.c,v 1.5 2016/07/21 08:39:23 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter @@ -328,8 +328,8 @@ ofp10_packet_in(struct switchd *sc, struct switch_connection *con, len = ntohs(pin->pin_total_len); srcport = ntohs(pin->pin_port); - if ((dstport = packet_input(sc, con->con_switch, - srcport, ibuf, len, &pkt)) == -1 || + if (packet_input(sc, con->con_switch, + srcport, &dstport, ibuf, len, &pkt) == -1 || dstport > OFP10_PORT_MAX) { /* fallback to flooding */ dstport = OFP10_PORT_FLOOD; diff --git a/usr.sbin/switchd/packet.c b/usr.sbin/switchd/packet.c index 089c06b2821..b24b8528abb 100644 --- a/usr.sbin/switchd/packet.c +++ b/usr.sbin/switchd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.2 2016/07/20 20:07:02 reyk Exp $ */ +/* $OpenBSD: packet.c,v 1.3 2016/07/21 08:39:23 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter @@ -50,9 +50,9 @@ packet_ether_unicast(uint8_t *ea) return (0); } -uint32_t -packet_input(struct switchd *sc, struct switch_control *sw, uint32_t port, - struct ibuf *ibuf, size_t len, struct packet *pkt) +int +packet_input(struct switchd *sc, struct switch_control *sw, uint32_t srcport, + uint32_t *dstport, struct ibuf *ibuf, size_t len, struct packet *pkt) { struct ether_header *eh; struct macaddr *src, *dst; @@ -70,7 +70,7 @@ packet_input(struct switchd *sc, struct switch_control *sw, uint32_t port, len -= sizeof(*eh); if ((packet_ether_unicast(eh->ether_shost) == -1) || - (src = switch_learn(sc, sw, eh->ether_shost, port)) == NULL) + (src = switch_learn(sc, sw, eh->ether_shost, srcport)) == NULL) return (-1); if (packet_ether_unicast(eh->ether_dhost) == -1) @@ -84,5 +84,8 @@ packet_input(struct switchd *sc, struct switch_control *sw, uint32_t port, src->mac_port, dst == NULL ? OFP_PORT_ANY : dst->mac_port); - return (dst == NULL ? OFP_PORT_ANY : dst->mac_port); + if (dstport) + *dstport = dst == NULL ? OFP_PORT_ANY : dst->mac_port; + + return (0); } diff --git a/usr.sbin/switchd/switchd.h b/usr.sbin/switchd/switchd.h index 5d707673c25..96bba1dab18 100644 --- a/usr.sbin/switchd/switchd.h +++ b/usr.sbin/switchd/switchd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: switchd.h,v 1.6 2016/07/21 07:58:44 reyk Exp $ */ +/* $OpenBSD: switchd.h,v 1.7 2016/07/21 08:39:23 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter @@ -134,8 +134,9 @@ int switchd_tap(void); int switchd_open_device(struct privsep *, const char *, size_t); /* packet.c */ -uint32_t packet_input(struct switchd *, struct switch_control *, - uint32_t, struct ibuf *, size_t, struct packet *); +int packet_input(struct switchd *, struct switch_control *, + uint32_t, uint32_t *, struct ibuf *, size_t, + struct packet *); /* switch.c */ void switch_init(struct switchd *); -- 2.20.1