You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.2 KiB

  1. From 86bd33a9f842caf1788b61d1f99e95f8ad866660 Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Wed, 25 Jun 2014 17:01:56 +0200
  4. Subject: [PATCH 6/6] BUG/MEDIUM: counters: fix track-sc* to wait on unstable
  5. contents
  6. I've been facing multiple configurations which involved track-sc* rules
  7. in tcp-request content without the "if ..." to force it to wait for the
  8. contents, resulting in random behaviour with contents sometimes retrieved
  9. and sometimes not.
  10. Reading the doc doesn't make it clear either that the tracking will be
  11. performed only if data are already there and that waiting on an ACL is
  12. the only way to avoid this.
  13. Since this behaviour is not natural and we now have the ability to fix
  14. it, this patch ensures that if input data are still moving, instead of
  15. silently dropping them, we naturally wait for them to stabilize up to
  16. the inspect-delay. This way it's not needed anymore to implement an
  17. ACL-based condition to force to wait for data, eventhough the behaviour
  18. is not changed for when an ACL is present.
  19. The most obvious usage will be when track-sc is followed by any HTTP
  20. sample expression, there's no need anymore for adding "if HTTP".
  21. It's probably worth backporting this to 1.5 to avoid further configuration
  22. issues. Note that it requires previous patch.
  23. (cherry picked from commit 1b71eb581ec1637879f725421efb95ad69f0ea4f)
  24. ---
  25. src/proto_tcp.c | 6 +++++-
  26. 1 file changed, 5 insertions(+), 1 deletion(-)
  27. diff --git a/src/proto_tcp.c b/src/proto_tcp.c
  28. index 1aac0d9..e9dbc9c 100644
  29. --- a/src/proto_tcp.c
  30. +++ b/src/proto_tcp.c
  31. @@ -1022,12 +1022,16 @@ int tcp_inspect_request(struct session *s, struct channel *req, int an_bit)
  32. * applies.
  33. */
  34. struct stktable_key *key;
  35. + struct sample smp;
  36. if (stkctr_entry(&s->stkctr[tcp_trk_idx(rule->action)]))
  37. continue;
  38. t = rule->act_prm.trk_ctr.table.t;
  39. - key = stktable_fetch_key(t, s->be, s, &s->txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->act_prm.trk_ctr.expr, NULL);
  40. + key = stktable_fetch_key(t, s->be, s, &s->txn, SMP_OPT_DIR_REQ | partial, rule->act_prm.trk_ctr.expr, &smp);
  41. +
  42. + if (smp.flags & SMP_F_MAY_CHANGE)
  43. + goto missing_data;
  44. if (key && (ts = stktable_get_entry(t, key))) {
  45. session_track_stkctr(&s->stkctr[tcp_trk_idx(rule->action)], t, ts);
  46. --
  47. 1.8.5.5