Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c6a700a

Browse files
acleonedormando
authored andcommitted
Fix udp mode when listening on ipv6 addresses.
Previously the memcached could not respond to ipv6 udp packets correctly, since the client's address was stored in a struct sockaddr (16 bytes on linux) instead of a struct sockaddr_in6 (28 bytes).
1 parent 7c512d0 commit c6a700a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

memcached.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3591,7 +3591,8 @@ static enum try_read_result try_read_udp(conn *c) {
35913591

35923592
c->request_addr_size = sizeof(c->request_addr);
35933593
res = recvfrom(c->sfd, c->rbuf, c->rsize,
3594-
0, &c->request_addr, &c->request_addr_size);
3594+
0, (struct sockaddr *)&c->request_addr,
3595+
&c->request_addr_size);
35953596
if (res > 8) {
35963597
unsigned char *buf = (unsigned char *)c->rbuf;
35973598
pthread_mutex_lock(&c->thread->stats.mutex);

memcached.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ struct conn {
437437

438438
/* data for UDP clients */
439439
int request_id; /* Incoming UDP request ID, if this is a UDP "connection" */
440-
struct sockaddr request_addr; /* Who sent the most recent request */
440+
struct sockaddr_in6 request_addr; /* udp: Who sent the most recent request */
441441
socklen_t request_addr_size;
442442
unsigned char *hdrbuf; /* udp packet headers */
443443
int hdrsize; /* number of headers' worth of space is allocated */

0 commit comments

Comments
 (0)