Skip to content

Commit e6f225e

Browse files
swegenerhorms
authored andcommitted
ipvs: Restrict sync message to 255 connections
The nr_conns variable in the sync message header is only eight bits wide and will overflow on interfaces with a large MTU. As a result the backup won't parse all connections contained in the sync buffer. On regular ethernet with an MTU of 1500 this isn't a problem, because we can't overflow the value, but consider jumbo frames being used on a cross-over connection between both directors. We now restrict the size of the sync buffer, so that we never put more than 255 connections into a single sync buffer. Signed-off-by: Sven Wegener <[email protected]> Signed-off-by: Simon Horman <[email protected]>
1 parent f5fff5d commit e6f225e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/ipv4/ipvs/ip_vs_sync.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/err.h>
3131
#include <linux/kthread.h>
3232
#include <linux/wait.h>
33+
#include <linux/kernel.h>
3334

3435
#include <net/ip.h>
3536
#include <net/sock.h>
@@ -99,6 +100,7 @@ struct ip_vs_sync_thread_data {
99100
*/
100101

101102
#define SYNC_MESG_HEADER_LEN 4
103+
#define MAX_CONNS_PER_SYNCBUFF 255 /* nr_conns in ip_vs_sync_mesg is 8 bit */
102104

103105
struct ip_vs_sync_mesg {
104106
__u8 nr_conns;
@@ -516,8 +518,8 @@ static int set_sync_mesg_maxlen(int sync_state)
516518
num = (dev->mtu - sizeof(struct iphdr) -
517519
sizeof(struct udphdr) -
518520
SYNC_MESG_HEADER_LEN - 20) / SIMPLE_CONN_SIZE;
519-
sync_send_mesg_maxlen =
520-
SYNC_MESG_HEADER_LEN + SIMPLE_CONN_SIZE * num;
521+
sync_send_mesg_maxlen = SYNC_MESG_HEADER_LEN +
522+
SIMPLE_CONN_SIZE * min(num, MAX_CONNS_PER_SYNCBUFF);
521523
IP_VS_DBG(7, "setting the maximum length of sync sending "
522524
"message %d.\n", sync_send_mesg_maxlen);
523525
} else if (sync_state == IP_VS_STATE_BACKUP) {

0 commit comments

Comments
 (0)