mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
BUG/MEDIUM: peers: properly skip conn_cur from incoming messages
The approach used for skipping conn_cur in commit db2ab8218 ("MEDIUM: stick-table: never learn the "conn_cur" value from peers") was wrong, it only works with simple tables but as soon as frequency counters or arrays are exchanged after conn_cur, the stream is desynchronized and incorrect values are read. This is because the fields have a variable length depending on their types and cannot simply be skipped by a "continue" statement. Let's change the approach to make sure we continue to completely parse these local-only fields, and only drop the value at the moment we're about to store them, since this is exactly the intent. A simpler approach could consist in having two sets of stktable_data_ptr() functions, one for retrieval and one for storage, and to make the store function return a NULL pointer for local types. For now this doesn't seem worth the trouble. This fixes github issue #1497. Thanks to @brenc for the reproducer. This must be backported to 2.5.
This commit is contained in:
parent
266d540549
commit
b4ff6f4ae9
22
src/peers.c
22
src/peers.c
@ -1774,12 +1774,12 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
|
||||
for (data_type = 0 ; data_type < STKTABLE_DATA_TYPES ; data_type++) {
|
||||
uint64_t decoded_int;
|
||||
unsigned int idx;
|
||||
int ignore;
|
||||
|
||||
if (!((1ULL << data_type) & st->remote_data))
|
||||
continue;
|
||||
|
||||
if (stktable_data_types[data_type].is_local)
|
||||
continue;
|
||||
ignore = stktable_data_types[data_type].is_local;
|
||||
|
||||
if (stktable_data_types[data_type].is_array) {
|
||||
/* in case of array all elements
|
||||
@ -1798,7 +1798,7 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
|
||||
}
|
||||
|
||||
data_ptr = stktable_data_ptr_idx(st->table, ts, data_type, idx);
|
||||
if (data_ptr)
|
||||
if (data_ptr && !ignore)
|
||||
stktable_data_cast(data_ptr, std_t_sint) = decoded_int;
|
||||
}
|
||||
break;
|
||||
@ -1811,7 +1811,7 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
|
||||
}
|
||||
|
||||
data_ptr = stktable_data_ptr_idx(st->table, ts, data_type, idx);
|
||||
if (data_ptr)
|
||||
if (data_ptr && !ignore)
|
||||
stktable_data_cast(data_ptr, std_t_uint) = decoded_int;
|
||||
}
|
||||
break;
|
||||
@ -1824,7 +1824,7 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
|
||||
}
|
||||
|
||||
data_ptr = stktable_data_ptr_idx(st->table, ts, data_type, idx);
|
||||
if (data_ptr)
|
||||
if (data_ptr && !ignore)
|
||||
stktable_data_cast(data_ptr, std_t_ull) = decoded_int;
|
||||
}
|
||||
break;
|
||||
@ -1858,7 +1858,7 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
|
||||
}
|
||||
|
||||
data_ptr = stktable_data_ptr_idx(st->table, ts, data_type, idx);
|
||||
if (data_ptr)
|
||||
if (data_ptr && !ignore)
|
||||
stktable_data_cast(data_ptr, std_t_frqp) = data;
|
||||
}
|
||||
break;
|
||||
@ -1878,19 +1878,19 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
|
||||
switch (stktable_data_types[data_type].std_type) {
|
||||
case STD_T_SINT:
|
||||
data_ptr = stktable_data_ptr(st->table, ts, data_type);
|
||||
if (data_ptr)
|
||||
if (data_ptr && !ignore)
|
||||
stktable_data_cast(data_ptr, std_t_sint) = decoded_int;
|
||||
break;
|
||||
|
||||
case STD_T_UINT:
|
||||
data_ptr = stktable_data_ptr(st->table, ts, data_type);
|
||||
if (data_ptr)
|
||||
if (data_ptr && !ignore)
|
||||
stktable_data_cast(data_ptr, std_t_uint) = decoded_int;
|
||||
break;
|
||||
|
||||
case STD_T_ULL:
|
||||
data_ptr = stktable_data_ptr(st->table, ts, data_type);
|
||||
if (data_ptr)
|
||||
if (data_ptr && !ignore)
|
||||
stktable_data_cast(data_ptr, std_t_ull) = decoded_int;
|
||||
break;
|
||||
|
||||
@ -1917,7 +1917,7 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
|
||||
}
|
||||
|
||||
data_ptr = stktable_data_ptr(st->table, ts, data_type);
|
||||
if (data_ptr)
|
||||
if (data_ptr && !ignore)
|
||||
stktable_data_cast(data_ptr, std_t_frqp) = data;
|
||||
break;
|
||||
}
|
||||
@ -1986,7 +1986,7 @@ static int peer_treat_updatemsg(struct appctx *appctx, struct peer *p, int updt,
|
||||
}
|
||||
if (de) {
|
||||
data_ptr = stktable_data_ptr(st->table, ts, data_type);
|
||||
if (data_ptr) {
|
||||
if (data_ptr && !ignore) {
|
||||
HA_ATOMIC_INC(&de->refcount);
|
||||
stktable_data_cast(data_ptr, std_t_dict) = de;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user