Skip to content

Commit f0523f2

Browse files
authored
Merge pull request #315 from lec-bit/release-0.3
[release-0.3]Fix the issue of incorrect domain matching
2 parents 521f0f2 + cfe9cb3 commit f0523f2

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

bpf/kmesh/include/route_config.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,22 @@ static inline Route__RouteConfiguration *map_lookup_route_config(const char *rou
4343
}
4444

4545
static inline int virtual_host_match_check(Route__VirtualHost *virt_host,
46-
address_t *addr, ctx_buff_t *ctx, struct bpf_mem_ptr *uri)
46+
address_t *addr, ctx_buff_t *ctx, struct bpf_mem_ptr *host)
4747
{
4848
int i;
4949
void *domains = NULL;
5050
void *domain = NULL;
5151
void *ptr;
5252
__u32 ptr_length;
5353

54-
if (!uri)
54+
if (!host)
5555
return 0;
5656

57-
ptr = _(uri->ptr);
57+
ptr = _(host->ptr);
5858
if (!ptr)
5959
return 0;
6060

61-
ptr_length = _(uri->size);
61+
ptr_length = _(host->size);
6262

6363
if (!virt_host->domains)
6464
return 0;
@@ -105,8 +105,8 @@ static inline Route__VirtualHost *virtual_host_match(Route__RouteConfiguration *
105105
void *ptrs = NULL;
106106
Route__VirtualHost *virt_host = NULL;
107107
Route__VirtualHost *virt_host_allow_any = NULL;
108-
char uri_key[4] = {'U', 'R', 'I', '\0'};
109-
struct bpf_mem_ptr *uri;
108+
char host_key[5] = {'H', 'o', 's', 't', '\0'};
109+
struct bpf_mem_ptr *host;
110110

111111
if (route_config->n_virtual_hosts <= 0 || route_config->n_virtual_hosts > KMESH_PER_VIRT_HOST_NUM) {
112112
BPF_LOG(WARN, ROUTER_CONFIG, "invalid virt hosts num=%d\n", route_config->n_virtual_hosts);
@@ -119,9 +119,9 @@ static inline Route__VirtualHost *virtual_host_match(Route__RouteConfiguration *
119119
return NULL;
120120
}
121121

122-
uri = bpf_get_msg_header_element(uri_key);
123-
if (!uri) {
124-
BPF_LOG(ERR, ROUTER_CONFIG, "failed to get URI in msg\n");
122+
host = bpf_get_msg_header_element(host_key);
123+
if (!host) {
124+
BPF_LOG(ERR, ROUTER_CONFIG, "failed to get Host in msg\n");
125125
return NULL;
126126
}
127127

@@ -139,11 +139,11 @@ static inline Route__VirtualHost *virtual_host_match(Route__RouteConfiguration *
139139
continue;
140140
}
141141

142-
if (virtual_host_match_check(virt_host, addr, ctx, uri))
142+
if (virtual_host_match_check(virt_host, addr, ctx, host))
143143
return virt_host;
144144
}
145145
// allow_any as the default virt_host
146-
if (virt_host_allow_any && virtual_host_match_check(virt_host_allow_any, addr, ctx, uri))
146+
if (virt_host_allow_any && virtual_host_match_check(virt_host_allow_any, addr, ctx, host))
147147
return virt_host_allow_any;
148148
return NULL;
149149
}

0 commit comments

Comments
 (0)