summaryrefslogtreecommitdiff
path: root/usr.sbin/switchd
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2016-07-21 08:39:24 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2016-07-21 08:39:24 +0000
commitf5d6892382f467fdc3630a364dd64df1e02ba978 (patch)
treede981a4bb16ca6054d696b5c8dadf77de1d3a7b0 /usr.sbin/switchd
parenta20cc5082a7f9bf7c18025285abeb7bc92bc6bfc (diff)
With uint32_t ports, we cannot sneak the port into an int anymore
Diffstat (limited to 'usr.sbin/switchd')
-rw-r--r--usr.sbin/switchd/ofp10.c6
-rw-r--r--usr.sbin/switchd/packet.c15
-rw-r--r--usr.sbin/switchd/switchd.h7
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 <reyk@openbsd.org>
@@ -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 <reyk@openbsd.org>
@@ -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 <reyk@openbsd.org>
@@ -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 *);