diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-07-20 20:07:03 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-07-20 20:07:03 +0000 |
commit | 60fea7cf5f25b3d446905ae0305149f0e4130245 (patch) | |
tree | 64f46cb45952528e098654929ba95a1ed9533cef | |
parent | 03fc1606cf1fe8fb101d32a806000c03d0a80e5c (diff) |
Handle ports as uint32_t instead of in_port_t: OpenFlow 1.0 used 16bit
ports, but later versions switched to 32bit ports (for the case that a
virtual switch has more than 65535 switch ports, of course).
-rw-r--r-- | usr.sbin/switchd/packet.c | 12 | ||||
-rw-r--r-- | usr.sbin/switchd/switch.c | 6 | ||||
-rw-r--r-- | usr.sbin/switchd/switchd.h | 10 |
3 files changed, 14 insertions, 14 deletions
diff --git a/usr.sbin/switchd/packet.c b/usr.sbin/switchd/packet.c index 39df7a9af2b..089c06b2821 100644 --- a/usr.sbin/switchd/packet.c +++ b/usr.sbin/switchd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.1 2016/07/19 16:54:26 reyk Exp $ */ +/* $OpenBSD: packet.c,v 1.2 2016/07/20 20:07:02 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -50,8 +50,8 @@ packet_ether_unicast(uint8_t *ea) return (0); } -long -packet_input(struct switchd *sc, struct switch_control *sw, long port, +uint32_t +packet_input(struct switchd *sc, struct switch_control *sw, uint32_t port, struct ibuf *ibuf, size_t len, struct packet *pkt) { struct ether_header *eh; @@ -78,11 +78,11 @@ packet_input(struct switchd *sc, struct switch_control *sw, long port, else dst = switch_cached(sw, eh->ether_dhost); - log_debug("%s: %s -> %s, port %ld -> %ld", __func__, + log_debug("%s: %s -> %s, port %u -> %u", __func__, print_ether(eh->ether_shost), print_ether(eh->ether_dhost), src->mac_port, - dst == NULL ? -1 : dst->mac_port); + dst == NULL ? OFP_PORT_ANY : dst->mac_port); - return (dst == NULL ? -1 : dst->mac_port); + return (dst == NULL ? OFP_PORT_ANY : dst->mac_port); } diff --git a/usr.sbin/switchd/switch.c b/usr.sbin/switchd/switch.c index a8cedb5fc84..26efb78736a 100644 --- a/usr.sbin/switchd/switch.c +++ b/usr.sbin/switchd/switch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: switch.c,v 1.1 2016/07/19 16:54:26 reyk Exp $ */ +/* $OpenBSD: switch.c,v 1.2 2016/07/20 20:07:02 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -184,7 +184,7 @@ switch_remove(struct switchd *sc, struct switch_control *sw) struct macaddr * switch_learn(struct switchd *sc, struct switch_control *sw, - uint8_t *ea, long port) + uint8_t *ea, uint32_t port) { struct macaddr *mac, *oldmac = NULL; struct timeval tv; @@ -209,7 +209,7 @@ switch_learn(struct switchd *sc, struct switch_control *sw, mac->mac_port = port; mac->mac_age = tv.tv_sec; - log_debug("%s: %s mac %s on switch %u port %ld", + log_debug("%s: %s mac %s on switch %u port %u", __func__, oldmac == NULL ? "learned new" : "updated", print_ether(ea), sw->sw_id, port); diff --git a/usr.sbin/switchd/switchd.h b/usr.sbin/switchd/switchd.h index be5c5ef6d41..ecf2e3a6187 100644 --- a/usr.sbin/switchd/switchd.h +++ b/usr.sbin/switchd/switchd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: switchd.h,v 1.3 2016/07/20 14:15:08 reyk Exp $ */ +/* $OpenBSD: switchd.h,v 1.4 2016/07/20 20:07:02 reyk Exp $ */ /* * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org> @@ -50,7 +50,7 @@ struct packet { struct macaddr { uint8_t mac_addr[ETHER_ADDR_LEN]; - long mac_port; + uint32_t mac_port; time_t mac_age; RB_ENTRY(macaddr) mac_entry; }; @@ -134,8 +134,8 @@ int switchd_tap(void); int switchd_open_device(struct privsep *, const char *, size_t); /* packet.c */ -long packet_input(struct switchd *, struct switch_control *, long, - struct ibuf *, size_t, struct packet *); +uint32_t packet_input(struct switchd *, struct switch_control *, + uint32_t, struct ibuf *, size_t, struct packet *); /* switch.c */ void switch_init(struct switchd *); @@ -147,7 +147,7 @@ void switch_remove(struct switchd *, struct switch_control *); struct switch_control *switch_get(struct switch_connection *); struct macaddr *switch_learn(struct switchd *, struct switch_control *, - uint8_t *, long); + uint8_t *, uint32_t); struct macaddr *switch_cached(struct switch_control *, uint8_t *); RB_PROTOTYPE(switch_head, switch_control, sw_entry, switch_cmp); RB_PROTOTYPE(macaddr_head, macaddr, mac_entry, switch_maccmp); |