Hi,

Is it possible to maintain gpc0/connection rate based on an arbitrary
pattern fetch?

My stick table is based on a header X-Session which is a string
pattern. I would like to rate limit based on UID it contains.

Backend config:
backend app
    balance     roundrobin
    server  app1 127.0.0.1:80 check cookie app1
    stick-table type string size 200k store gpc0
    stick on uid

We have implemented uid as a custom pattern fetch in code with


static int
pattern_fetch_uid(struct proxy *px, struct session *l4, void *l7, int dir,
                     const struct pattern_arg *arg_p, int arg_i, union
pattern_data *data)
{
        struct hdr_ctx ctx;
        struct http_txn *txn = l7;
        struct http_msg *msg = &txn->req;
        const char *hdr;
        int hdr_len;
        uauth_t uauth;

        ctx.idx = 0;
        if(http_find_header2("X-Session", sizeof("X-Session")-1,
msg->sol, &txn->hdr_idx, &ctx)) {
 ....
       return 1;
       }
}


static struct pattern_fetch_kw_list pattern_fetch_keywords = {{ },{
        { "uid", pattern_fetch_uid, NULL, PATTERN_TYPE_STRING,
PATTERN_FETCH_REQ },
        { NULL, NULL, NULL, 0, 0 },
}};


>From the stats output, it is observed that gpc0 is not getting incremented.
> show table app
# table: app, type: string, size:204800, used:8
0xa510398: key=001 use=0 exp=0 server_id=1 gpc0=0
0xa518f18: key=11859 use=0 exp=0 server_id=1 gpc0=0
0xa519188: key=12375 use=0 exp=0 server_id=1 gpc0=0
0xa518d78: key=12603 use=0 exp=0 server_id=1 gpc0=0
0xa5190b8: key=17522 use=0 exp=0 server_id=1 gpc0=0
0xa518fe8: key=31653 use=0 exp=0 server_id=1 gpc0=0
0xa510468: key=31943 use=0 exp=0 server_id=1 gpc0=0
0xa518e48: key=3325 use=0 exp=0 server_id=1 gpc0=0

Is there a generic configuration operation to increment/get gpc0. e.g.

stick increment gpc0
acl abuse  stick_get_gpc0 gt 10

Also, we would like to use frequency counter for this. e.g.
acl abuse stick_get_gpfc0 gt 10

Thanks,
Harshad

Reply via email to