tcp_splice: Use unsigned to represent side
Currently, we use 'int' values to represent the "side" of a connection, which must always be 0 or 1. This turns out to be dangerous. In some cases we're going to want to put the side into a 1-bit bitfield. However, if that bitfield has type 'int', when we copy it out to a regular 'int' variable, it will be sign-extended and so have values 0 and -1, instead of 0 and 1. To avoid this, always use unsigned variables for the side. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
ecea8d36ff
commit
788d2fe3ce
1 changed files with 4 additions and 3 deletions
|
@ -249,7 +249,7 @@ void tcp_splice_conn_update(const struct ctx *c, struct tcp_splice_conn *new)
|
|||
void tcp_splice_destroy(struct ctx *c, union flow *flow)
|
||||
{
|
||||
struct tcp_splice_conn *conn = &flow->tcp_splice;
|
||||
int side;
|
||||
unsigned side;
|
||||
|
||||
for (side = 0; side < SIDES; side++) {
|
||||
if (conn->events & SPLICE_ESTABLISHED) {
|
||||
|
@ -286,8 +286,8 @@ void tcp_splice_destroy(struct ctx *c, union flow *flow)
|
|||
static int tcp_splice_connect_finish(const struct ctx *c,
|
||||
struct tcp_splice_conn *conn)
|
||||
{
|
||||
unsigned side;
|
||||
int i = 0;
|
||||
int side;
|
||||
|
||||
for (side = 0; side < SIDES; side++) {
|
||||
conn->pipe[side][0] = conn->pipe[side][1] = -1;
|
||||
|
@ -490,7 +490,8 @@ void tcp_splice_sock_handler(struct ctx *c, struct tcp_splice_conn *conn,
|
|||
int s, uint32_t events)
|
||||
{
|
||||
uint8_t lowat_set_flag, lowat_act_flag;
|
||||
int fromside, eof, never_read;
|
||||
int eof, never_read;
|
||||
unsigned fromside;
|
||||
|
||||
if (conn->events == SPLICE_CLOSED)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue