Hi all,
Currently, switchd(8) defaults to listening on port 6633, which was
the defacto port value used by OpenFlow. A decent chunk of OpenFlow
controllers have switched over to the IANA standardized OpenFlow port,
6653. While testing the change, I noticed that switchd(8) will listen on
random ports if one isn't specified in switchd.conf(5), e.g:
listen on 127.0.0.1
The following consolidates the #defines for port values, and also sets a
default listen port when it isn't specified in switchd.conf(5).
Comments/OKs?
Thanks,
Ayaka
Index: parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/switchd/parse.y,v
retrieving revision 1.12
diff -u -p -u -r1.12 parse.y
--- parse.y 1 Nov 2018 00:18:44 -0000 1.12
+++ parse.y 7 Nov 2018 06:35:03 -0000
@@ -146,6 +146,8 @@ listen : LISTEN ON STRING opttls port {
YYERROR;
}
free($3);
+ ((struct sockaddr_in *)&conf->sc_server.srv_addr)
+ ->sin_port = htons(SWITCHD_CTLR_PORT);
}
;
@@ -627,7 +629,7 @@ parse_config(const char *filename, struc
conf = sc;
- /* Set the default 0.0.0.0 6633/tcp */
+ /* Set the default 0.0.0.0 6653/tcp */
memset(&conf->sc_server.srv_addr, 0, sizeof(conf->sc_server.srv_addr));
sin4 = (struct sockaddr_in *)&conf->sc_server.srv_addr;
sin4->sin_family = AF_INET;
Index: types.h
===================================================================
RCS file: /cvs/src/usr.sbin/switchd/types.h,v
retrieving revision 1.10
diff -u -p -u -r1.10 types.h
--- types.h 18 Nov 2016 16:49:35 -0000 1.10
+++ types.h 7 Nov 2018 06:35:03 -0000
@@ -37,8 +37,7 @@
#define SWITCHD_MAX_TAP 256
#define SWITCHD_MAX_SESSIONS 0xffff
-#define SWITCHD_CTLR_PORT 6633 /* Previously used by OpenFlow */
-#define SWITCHD_CTLR_IANA_PORT 6653 /* Assigned by IANA for OpenFlow */
+#define SWITCHD_CTLR_PORT 6653 /* Assigned by IANA for OpenFlow */
#define SWITCHD_CACHE_MAX 4096 /* Default MAC address cache limit */
#define SWITCHD_CACHE_TIMEOUT 240 /* t/o in seconds for learned MACs */