move parse-msg-header and proto-check to L7 http_manage_filter

Signed-off-by: superCharge <xiesongyang@huawei.com>
This commit is contained in:
superCharge 2023-08-02 14:26:33 +08:00
parent 0221defedf
commit 3c8d866efd
3 changed files with 7 additions and 10 deletions

View File

@ -83,6 +83,10 @@ int filter_manager(ctx_buff_t *ctx)
switch (filter->config_type_case) {
case LISTENER__FILTER__CONFIG_TYPE_HTTP_CONNECTION_MANAGER:
http_conn = kmesh_get_ptr_val(filter->http_connection_manager);
if (bpf_parse_header_msg(ctx_val->msg) != PROTO_HTTP_1_1) {
BPF_LOG(DEBUG, FILTER, "http filter manager,only support http1.1 this version");
return 0;
}
if (!http_conn) {
BPF_LOG(ERR, FILTER, "get http_conn failed\n");
ret = -1;

View File

@ -107,7 +107,7 @@ static inline int listener_filter_chain_match(const Listener__Listener *listener
return -1;
}
static inline int l7_listener_manager(ctx_buff_t *ctx, Listener__Listener *listener, struct bpf_mem_ptr *msg)
static inline int listener_manager(ctx_buff_t *ctx, Listener__Listener *listener, struct bpf_mem_ptr *msg)
{
int ret = 0;
__u64 filter_chain_idx = 0;
@ -137,7 +137,7 @@ static inline int l7_listener_manager(ctx_buff_t *ctx, Listener__Listener *liste
kmesh_tail_call(ctx, KMESH_TAIL_CALL_FILTER_CHAIN);
(void)kmesh_tail_delete_ctx(&ctx_key);
BPF_LOG(ERR, LISTENER, "l7_listener_manager exit\n");
BPF_LOG(ERR, LISTENER, "listener_manager exit\n");
return ret;
}
#endif

View File

@ -41,14 +41,7 @@ static int sockops_traffic_control(struct bpf_sock_ops *skops, struct bpf_mem_pt
BPF_LOG(DEBUG, SOCKOPS, "sockops_traffic_control listener=\"%s\", addr=[%u:%u]\n",
(char *)kmesh_get_ptr_val(listener->name), skops->remote_ip4, skops->remote_port);
ret = bpf_parse_header_msg(msg);
if (GET_RET_PROTO_TYPE(ret) != PROTO_HTTP_1_1) {
BPF_LOG(DEBUG, SOCKOPS, "sockops_traffic_control listener=\"%s\", remote_ip:%u, ret:%d\n",
(char *)kmesh_get_ptr_val(listener->name), skops->remote_ip4, ret);
return 0;
}
return l7_listener_manager(skops, listener, msg);
return listener_manager(skops, listener, msg);
}
SEC("sockops")