2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-27 15:18:06 +00:00

socket-util: Remove DSCP_INVALID.

The DSCP_INVALID flag allowed callers to prevent socket-util from
modify the DSCP bits of newly created sockets.  However, the two
really important callers (implementations of the controller and
manager tables) never used it.  Furthermore, the other callers
would be fine always setting the DSCP bits to zero.  This patch
removes the DSCP_INVALID option in an effort to simplify the code.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
This commit is contained in:
Ethan Jackson
2012-04-16 13:56:58 -07:00
parent 317f642076
commit ef8a3d1497
8 changed files with 18 additions and 38 deletions

View File

@@ -546,8 +546,7 @@ exit:
* If 'sinp' is non-null, then on success the target address is stored into * If 'sinp' is non-null, then on success the target address is stored into
* '*sinp'. * '*sinp'.
* *
* 'dscp' If not DSCP_INVALID, its value becomes the DSCP bits in the IP * 'dscp' becomes the DSCP bits in the IP headers for the new connection. */
* headers for the new connection. */
int int
inet_open_active(int style, const char *target, uint16_t default_port, inet_open_active(int style, const char *target, uint16_t default_port,
struct sockaddr_in *sinp, int *fdp, uint8_t dscp) struct sockaddr_in *sinp, int *fdp, uint8_t dscp)
@@ -577,12 +576,10 @@ inet_open_active(int style, const char *target, uint16_t default_port,
/* The socket options set here ensure that the TOS bits are set during /* The socket options set here ensure that the TOS bits are set during
* the connection establishment. If set after connect(), the handshake * the connection establishment. If set after connect(), the handshake
* SYN frames will be sent with a TOS of 0. */ * SYN frames will be sent with a TOS of 0. */
if (dscp != DSCP_INVALID) { if (setsockopt(fd, IPPROTO_IP, IP_TOS, &dscp, sizeof dscp)) {
if (setsockopt(fd, IPPROTO_IP, IP_TOS, &dscp, sizeof dscp)) { VLOG_ERR("%s: socket: %s", target, strerror(errno));
VLOG_ERR("%s: socket: %s", target, strerror(errno)); error = errno;
error = errno; goto exit;
goto exit;
}
} }
/* Connect. */ /* Connect. */
@@ -672,8 +669,7 @@ exit:
* If 'sinp' is non-null, then on success the bound address is stored into * If 'sinp' is non-null, then on success the bound address is stored into
* '*sinp'. * '*sinp'.
* *
* 'dscp' If not DSCP_INVALID, its value becomes the DSCP bits in the IP * 'dscp' becomes the DSCP bits in the IP headers for the new connection. */
* headers for the new connection. */
int int
inet_open_passive(int style, const char *target, int default_port, inet_open_passive(int style, const char *target, int default_port,
struct sockaddr_in *sinp, uint8_t dscp) struct sockaddr_in *sinp, uint8_t dscp)
@@ -714,12 +710,10 @@ inet_open_passive(int style, const char *target, int default_port,
/* The socket options set here ensure that the TOS bits are set during /* The socket options set here ensure that the TOS bits are set during
* the connection establishment. If set after connect(), the handshake * the connection establishment. If set after connect(), the handshake
* SYN frames will be sent with a TOS of 0. */ * SYN frames will be sent with a TOS of 0. */
if (dscp != DSCP_INVALID) { if (setsockopt(fd, IPPROTO_IP, IP_TOS, &dscp, sizeof dscp)) {
if (setsockopt(fd, IPPROTO_IP, IP_TOS, &dscp, sizeof dscp)) { VLOG_ERR("%s: socket: %s", target, strerror(errno));
VLOG_ERR("%s: socket: %s", target, strerror(errno)); error = errno;
error = errno; goto error;
goto error;
}
} }
/* Listen. */ /* Listen. */

View File

@@ -69,9 +69,4 @@ char *describe_fd(int fd);
* in <netinet/ip.h> is used. */ * in <netinet/ip.h> is used. */
#define DSCP_DEFAULT IPTOS_PREC_INTERNETCONTROL #define DSCP_DEFAULT IPTOS_PREC_INTERNETCONTROL
/* Invalid dscp value. If the dscp value will not be used, the dscp value
* passed must be invalid. Set to 0xFF as the TOS bits passed can only be
* 6 bits. */
#define DSCP_INVALID 0xFF
#endif /* socket-util.h */ #endif /* socket-util.h */

View File

@@ -65,9 +65,7 @@ struct stream_class {
* *
* 'suffix' is a copy of 'name' following the colon and may be modified. * 'suffix' is a copy of 'name' following the colon and may be modified.
* 'dscp' is the DSCP value that the new connection should use in the IP * 'dscp' is the DSCP value that the new connection should use in the IP
* packets it sends. (If no DSCP value should be set in the packet, dscp * packets it sends.
* will be set to DSCP_INVALID. If no DSCP value is specified, DSCP_DEFAULT
* value will be applied.)
* *
* Returns 0 if successful, otherwise a positive errno value. If * Returns 0 if successful, otherwise a positive errno value. If
* successful, stores a pointer to the new connection in '*streamp'. * successful, stores a pointer to the new connection in '*streamp'.
@@ -167,9 +165,7 @@ struct pstream_class {
* *
* 'suffix' is a copy of 'name' following the colon and may be modified. * 'suffix' is a copy of 'name' following the colon and may be modified.
* 'dscp' is the DSCP value that the new connection should use in the IP * 'dscp' is the DSCP value that the new connection should use in the IP
* packets it sends. (If no DSCP value should be set in the packet, dscp * packets it sends.
* will be set to DSCP_INVALID. If no DSCP value is specified, DSCP_DEFAULT
* value will be applied.)
* *
* Returns 0 if successful, otherwise a positive errno value. If * Returns 0 if successful, otherwise a positive errno value. If
* successful, stores a pointer to the new connection in '*pstreamp'. * successful, stores a pointer to the new connection in '*pstreamp'.

View File

@@ -221,7 +221,7 @@ unixctl_server_create(const char *path, struct unixctl_server **serverp)
program_name, (long int) getpid()); program_name, (long int) getpid());
} }
error = pstream_open(punix_path, &listener, DSCP_INVALID); error = pstream_open(punix_path, &listener, 0);
if (error) { if (error) {
ovs_error(error, "could not initialize control socket %s", punix_path); ovs_error(error, "could not initialize control socket %s", punix_path);
goto exit; goto exit;

View File

@@ -63,9 +63,7 @@ struct vconn_class {
* *
* 'suffix' is a copy of 'name' following the colon and may be modified. * 'suffix' is a copy of 'name' following the colon and may be modified.
* 'dscp' is the DSCP value that the new connection should use in the IP * 'dscp' is the DSCP value that the new connection should use in the IP
* packets it sends. (If no DSCP value should be set in the packet, dscp * packets it sends.
* will be set to DSCP_INVALID. If no DSCP value is specified, DSCP_DEFAULT
* value will be applied.)
* *
* Returns 0 if successful, otherwise a positive errno value. If * Returns 0 if successful, otherwise a positive errno value. If
* successful, stores a pointer to the new connection in '*vconnp'. * successful, stores a pointer to the new connection in '*vconnp'.
@@ -155,9 +153,7 @@ struct pvconn_class {
* *
* 'suffix' is a copy of 'name' following the colon and may be modified. * 'suffix' is a copy of 'name' following the colon and may be modified.
* 'dscp' is the DSCP value that the new connection should use in the IP * 'dscp' is the DSCP value that the new connection should use in the IP
* packets it sends. (If no DSCP value should be set in the packet, dscp * packets it sends.
* will be set to DSCP_INVALID. If no DSCP value is specified, DSCP_DEFAULT
* value will be applied.)
* *
* Returns 0 if successful, otherwise a positive errno value. If * Returns 0 if successful, otherwise a positive errno value. If
* successful, stores a pointer to the new connection in '*pvconnp'. * successful, stores a pointer to the new connection in '*pvconnp'.

View File

@@ -63,8 +63,7 @@ collectors_create(const struct sset *targets, uint16_t default_port,
int error; int error;
int fd; int fd;
error = inet_open_active(SOCK_DGRAM, name, default_port, NULL, &fd, error = inet_open_active(SOCK_DGRAM, name, default_port, NULL, &fd, 0);
DSCP_INVALID);
if (fd >= 0) { if (fd >= 0) {
c->fds[c->n_fds++] = fd; c->fds[c->n_fds++] = fd;
} else { } else {

View File

@@ -674,7 +674,7 @@ set_pvconns(struct pvconn ***pvconnsp, size_t *n_pvconnsp,
struct pvconn *pvconn; struct pvconn *pvconn;
int error; int error;
error = pvconn_open(name, &pvconn, DSCP_INVALID); error = pvconn_open(name, &pvconn, 0);
if (!error) { if (!error) {
pvconns[n_pvconns++] = pvconn; pvconns[n_pvconns++] = pvconn;
} else { } else {

View File

@@ -202,7 +202,7 @@ main(int argc, char *argv[])
} }
target = argv[optind]; target = argv[optind];
sock = inet_open_passive(SOCK_DGRAM, target, 0, NULL, DSCP_INVALID); sock = inet_open_passive(SOCK_DGRAM, target, 0, NULL, 0);
if (sock < 0) { if (sock < 0) {
ovs_fatal(0, "%s: failed to open (%s)", argv[1], strerror(-sock)); ovs_fatal(0, "%s: failed to open (%s)", argv[1], strerror(-sock));
} }