mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MINOR: quic: pass quic_dgram as obj_type for quic-initial rules
To extend quic-initial rules, pass quic_dgram instance to argument for the various actions. As such, quic_dgram is now supported as an obj_type and can be used in session origin field.
This commit is contained in:
parent
1259700763
commit
f91be2657e
@ -43,6 +43,9 @@ enum obj_type {
|
|||||||
OBJ_TYPE_SC, /* object is a struct stconn */
|
OBJ_TYPE_SC, /* object is a struct stconn */
|
||||||
OBJ_TYPE_STREAM, /* object is a struct stream */
|
OBJ_TYPE_STREAM, /* object is a struct stream */
|
||||||
OBJ_TYPE_CHECK, /* object is a struct check */
|
OBJ_TYPE_CHECK, /* object is a struct check */
|
||||||
|
#ifdef USE_QUIC
|
||||||
|
OBJ_TYPE_DGRAM, /* object is a struct quic_dgram */
|
||||||
|
#endif
|
||||||
OBJ_TYPE_ENTRIES /* last one : number of entries */
|
OBJ_TYPE_ENTRIES /* last one : number of entries */
|
||||||
} __attribute__((packed)) ;
|
} __attribute__((packed)) ;
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <haproxy/obj_type-t.h>
|
#include <haproxy/obj_type-t.h>
|
||||||
#include <haproxy/pool.h>
|
#include <haproxy/pool.h>
|
||||||
#include <haproxy/proxy-t.h>
|
#include <haproxy/proxy-t.h>
|
||||||
|
#include <haproxy/quic_sock-t.h>
|
||||||
#include <haproxy/server-t.h>
|
#include <haproxy/server-t.h>
|
||||||
#include <haproxy/stream-t.h>
|
#include <haproxy/stream-t.h>
|
||||||
|
|
||||||
@ -54,6 +55,9 @@ static inline const char *obj_type_name(const enum obj_type *t)
|
|||||||
case OBJ_TYPE_SC: return "SC";
|
case OBJ_TYPE_SC: return "SC";
|
||||||
case OBJ_TYPE_STREAM: return "STREAM";
|
case OBJ_TYPE_STREAM: return "STREAM";
|
||||||
case OBJ_TYPE_CHECK: return "CHECK";
|
case OBJ_TYPE_CHECK: return "CHECK";
|
||||||
|
#ifdef USE_QUIC
|
||||||
|
case OBJ_TYPE_DGRAM: return "DGRAM";
|
||||||
|
#endif
|
||||||
default: return "!INVAL!";
|
default: return "!INVAL!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,6 +189,20 @@ static inline struct check *objt_check(enum obj_type *t)
|
|||||||
return __objt_check(t);
|
return __objt_check(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_QUIC
|
||||||
|
static inline struct quic_dgram *__objt_dgram(enum obj_type *t)
|
||||||
|
{
|
||||||
|
return container_of(t, struct quic_dgram, obj_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct quic_dgram *objt_dgram(enum obj_type *t)
|
||||||
|
{
|
||||||
|
if (!t || *t != OBJ_TYPE_DGRAM)
|
||||||
|
return NULL;
|
||||||
|
return __objt_dgram(t);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void *obj_base_ptr(enum obj_type *t)
|
static inline void *obj_base_ptr(enum obj_type *t)
|
||||||
{
|
{
|
||||||
switch (obj_type(t)) {
|
switch (obj_type(t)) {
|
||||||
@ -199,6 +217,9 @@ static inline void *obj_base_ptr(enum obj_type *t)
|
|||||||
case OBJ_TYPE_SC: return __objt_sc(t);
|
case OBJ_TYPE_SC: return __objt_sc(t);
|
||||||
case OBJ_TYPE_STREAM: return __objt_stream(t);
|
case OBJ_TYPE_STREAM: return __objt_stream(t);
|
||||||
case OBJ_TYPE_CHECK: return __objt_check(t);
|
case OBJ_TYPE_CHECK: return __objt_check(t);
|
||||||
|
#ifdef USE_QUIC
|
||||||
|
case OBJ_TYPE_DGRAM: return __objt_dgram(t);
|
||||||
|
#endif
|
||||||
default: return t; // exact pointer for invalid case
|
default: return t; // exact pointer for invalid case
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
#ifndef _HAPROXY_QUIC_RULES_H
|
#ifndef _HAPROXY_QUIC_RULES_H
|
||||||
#define _HAPROXY_QUIC_RULES_H
|
#define _HAPROXY_QUIC_RULES_H
|
||||||
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include <haproxy/action-t.h>
|
#include <haproxy/action-t.h>
|
||||||
|
#include <haproxy/quic_sock-t.h>
|
||||||
|
|
||||||
struct listener;
|
struct listener;
|
||||||
|
struct quic_dgram;
|
||||||
|
|
||||||
extern struct action_kw_list quic_init_actions_list;
|
extern struct action_kw_list quic_init_actions_list;
|
||||||
|
|
||||||
int quic_init_exec_rules(struct listener *li,
|
int quic_init_exec_rules(struct listener *li, struct quic_dgram *dgram);
|
||||||
struct sockaddr_storage *saddr,
|
|
||||||
struct sockaddr_storage *daddr);
|
|
||||||
|
|
||||||
struct action_kw *action_quic_init_custom(const char *kw);
|
struct action_kw *action_quic_init_custom(const char *kw);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#ifdef USE_QUIC
|
#ifdef USE_QUIC
|
||||||
|
|
||||||
#include <haproxy/buf-t.h>
|
#include <haproxy/buf-t.h>
|
||||||
|
#include <haproxy/obj_type-t.h>
|
||||||
|
|
||||||
/* QUIC socket allocation strategy. */
|
/* QUIC socket allocation strategy. */
|
||||||
enum quic_sock_mode {
|
enum quic_sock_mode {
|
||||||
@ -27,6 +28,7 @@ struct quic_receiver_buf {
|
|||||||
|
|
||||||
/* QUIC datagram */
|
/* QUIC datagram */
|
||||||
struct quic_dgram {
|
struct quic_dgram {
|
||||||
|
enum obj_type obj_type;
|
||||||
void *owner;
|
void *owner;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
#include <haproxy/action.h>
|
#include <haproxy/action.h>
|
||||||
#include <haproxy/list.h>
|
#include <haproxy/list.h>
|
||||||
#include <haproxy/listener.h>
|
#include <haproxy/listener.h>
|
||||||
|
#include <haproxy/obj_type.h>
|
||||||
#include <haproxy/proxy-t.h>
|
#include <haproxy/proxy-t.h>
|
||||||
|
#include <haproxy/quic_sock-t.h>
|
||||||
#include <haproxy/sample-t.h>
|
#include <haproxy/sample-t.h>
|
||||||
#include <haproxy/session-t.h>
|
#include <haproxy/session-t.h>
|
||||||
|
|
||||||
/* Execute registered quic-initial rules on proxy owning <li> listener. */
|
/* Execute registered quic-initial rules on proxy owning <li> listener after
|
||||||
int quic_init_exec_rules(struct listener *li,
|
* <dgram> reception.
|
||||||
struct sockaddr_storage *saddr,
|
*/
|
||||||
struct sockaddr_storage *daddr)
|
int quic_init_exec_rules(struct listener *li, struct quic_dgram *dgram)
|
||||||
{
|
{
|
||||||
static THREAD_LOCAL struct session rule_sess;
|
static THREAD_LOCAL struct session rule_sess;
|
||||||
struct act_rule *rule;
|
struct act_rule *rule;
|
||||||
@ -26,8 +28,9 @@ int quic_init_exec_rules(struct listener *li,
|
|||||||
*/
|
*/
|
||||||
rule_sess.fe = px;
|
rule_sess.fe = px;
|
||||||
rule_sess.listener = li;
|
rule_sess.listener = li;
|
||||||
rule_sess.src = saddr;
|
rule_sess.src = &dgram->saddr;
|
||||||
rule_sess.dst = daddr;
|
rule_sess.dst = &dgram->daddr;
|
||||||
|
rule_sess.origin = &dgram->obj_type;
|
||||||
|
|
||||||
list_for_each_entry(rule, &px->quic_init_rules, list) {
|
list_for_each_entry(rule, &px->quic_init_rules, list) {
|
||||||
ret = ACL_TEST_PASS;
|
ret = ACL_TEST_PASS;
|
||||||
|
@ -1607,7 +1607,7 @@ static struct quic_conn *quic_rx_pkt_retrieve_conn(struct quic_rx_packet *pkt,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quic_init_exec_rules(l, &dgram->saddr, &dgram->daddr)) {
|
if (!quic_init_exec_rules(l, dgram)) {
|
||||||
TRACE_USER("drop datagram on quic-initial rules", QUIC_EV_CONN_LPKT, NULL, NULL, NULL, pkt->version);
|
TRACE_USER("drop datagram on quic-initial rules", QUIC_EV_CONN_LPKT, NULL, NULL, NULL, pkt->version);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <haproxy/list.h>
|
#include <haproxy/list.h>
|
||||||
#include <haproxy/listener.h>
|
#include <haproxy/listener.h>
|
||||||
#include <haproxy/log.h>
|
#include <haproxy/log.h>
|
||||||
|
#include <haproxy/obj_type.h>
|
||||||
#include <haproxy/pool.h>
|
#include <haproxy/pool.h>
|
||||||
#include <haproxy/protocol-t.h>
|
#include <haproxy/protocol-t.h>
|
||||||
#include <haproxy/proto_quic.h>
|
#include <haproxy/proto_quic.h>
|
||||||
@ -285,6 +286,7 @@ static int quic_lstnr_dgram_dispatch(unsigned char *pos, size_t len, void *owner
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* All the members must be initialized! */
|
/* All the members must be initialized! */
|
||||||
|
dgram->obj_type = OBJ_TYPE_DGRAM;
|
||||||
dgram->owner = owner;
|
dgram->owner = owner;
|
||||||
dgram->buf = pos;
|
dgram->buf = pos;
|
||||||
dgram->len = len;
|
dgram->len = len;
|
||||||
@ -849,6 +851,7 @@ int qc_rcv_buf(struct quic_conn *qc)
|
|||||||
|
|
||||||
b_add(&buf, ret);
|
b_add(&buf, ret);
|
||||||
|
|
||||||
|
new_dgram->obj_type = OBJ_TYPE_DGRAM;
|
||||||
new_dgram->buf = dgram_buf;
|
new_dgram->buf = dgram_buf;
|
||||||
new_dgram->len = ret;
|
new_dgram->len = ret;
|
||||||
new_dgram->dcid_len = 0;
|
new_dgram->dcid_len = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user