Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc79dd1b authored by Ying Xue's avatar Ying Xue Committed by David S. Miller
Browse files

tipc: change socket buffer overflow control to respect sk_rcvbuf



As per feedback from the netdev community, we change the buffer
overflow protection algorithm in receiving sockets so that it
always respects the nominal upper limit set in sk_rcvbuf.

Instead of scaling up from a small sk_rcvbuf value, which leads to
violation of the configured sk_rcvbuf limit, we now calculate the
weighted per-message limit by scaling down from a much bigger value,
still in the same field, according to the importance priority of the
received message.

To allow for administrative tunability of the socket receive buffer
size, we create a tipc_rmem sysctl variable to allow the user to
configure an even bigger value via sysctl command.  It is a size of
three (min/default/max) to be consistent with things like tcp_rmem.

By default, the value initialized in tipc_rmem[1] is equal to the
receive socket size needed by a TIPC_CRITICAL_IMPORTANCE message.
This value is also set as the default value of sk_rcvbuf.

Originally-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: Jon Maloy <jon.maloy@ericsson.com>
[Ying: added sysctl variation to Jon's original patch]
Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
[PG: don't compile sysctl.c if not config'd; add Documentation]
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8941bbcd
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ Table : Subdirectories in /proc/sys/net
 ipv4      IP version 4        x25        X.25 protocol
 ipx       IPX                 token-ring IBM token ring
 bridge    Bridging            decnet     DEC net
 ipv6      IP version 6
 ipv6      IP version 6        tipc       TIPC
..............................................................................

1. /proc/sys/net/core - Network core options
@@ -207,3 +207,18 @@ IPX.
The /proc/net/ipx_route  table  holds  a list of IPX routes. For each route it
gives the  destination  network, the router node (or Directly) and the network
address of the router (or Connected) for internal networks.

6. TIPC
-------------------------------------------------------

The TIPC protocol now has a tunable for the receive memory, similar to the
tcp_rmem - i.e. a vector of 3 INTEGERs: (min, default, max)

    # cat /proc/sys/net/tipc/tipc_rmem
    4252725 34021800        68043600
    #

The max value is set to CONN_OVERLOAD_LIMIT, and the default and min values
are scaled (shifted) versions of that same value.  Note that the min value
is not at this point in time used in any meaningful way, but the triplet is
preserved in order to be consistent with things like tcp_rmem.
+1 −0
Original line number Diff line number Diff line
@@ -11,3 +11,4 @@ tipc-y += addr.o bcast.o bearer.o config.o \
	   socket.o log.o eth_media.o

tipc-$(CONFIG_TIPC_MEDIA_IB)	+= ib_media.o
tipc-$(CONFIG_SYSCTL)		+= sysctl.o
+10 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "name_table.h"
#include "subscr.h"
#include "config.h"
#include "port.h"

#include <linux/module.h>

@@ -50,7 +51,7 @@ u32 tipc_own_addr __read_mostly;
int tipc_max_ports __read_mostly;
int tipc_net_id __read_mostly;
int tipc_remote_management __read_mostly;

int sysctl_tipc_rmem[3] __read_mostly;	/* min/default/max */

/**
 * tipc_buf_acquire - creates a TIPC message buffer
@@ -118,6 +119,7 @@ static void tipc_core_stop(void)
	tipc_nametbl_stop();
	tipc_ref_table_stop();
	tipc_socket_stop();
	tipc_unregister_sysctl();
}

/**
@@ -142,13 +144,14 @@ static int tipc_core_start(void)
		res = tipc_netlink_start();
	if (!res)
		res = tipc_socket_init();
	if (!res)
		res = tipc_register_sysctl();
	if (res)
		tipc_core_stop();

	return res;
}


static int __init tipc_init(void)
{
	int res;
@@ -160,6 +163,11 @@ static int __init tipc_init(void)
	tipc_max_ports = CONFIG_TIPC_PORTS;
	tipc_net_id = 4711;

	sysctl_tipc_rmem[0] = CONN_OVERLOAD_LIMIT >> 4 << TIPC_LOW_IMPORTANCE;
	sysctl_tipc_rmem[1] = CONN_OVERLOAD_LIMIT >> 4 <<
			      TIPC_CRITICAL_IMPORTANCE;
	sysctl_tipc_rmem[2] = CONN_OVERLOAD_LIMIT;

	res = tipc_core_start();
	if (res)
		pr_err("Unable to start in single node mode\n");
+9 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ extern u32 tipc_own_addr __read_mostly;
extern int tipc_max_ports __read_mostly;
extern int tipc_net_id __read_mostly;
extern int tipc_remote_management __read_mostly;
extern int sysctl_tipc_rmem[3] __read_mostly;

/*
 * Other global variables
@@ -97,6 +98,14 @@ extern void tipc_netlink_stop(void);
extern int  tipc_socket_init(void);
extern void tipc_socket_stop(void);

#ifdef CONFIG_SYSCTL
extern int tipc_register_sysctl(void);
extern void tipc_unregister_sysctl(void);
#else
#define tipc_register_sysctl() 0
#define tipc_unregister_sysctl()
#endif

/*
 * TIPC timer and signal code
 */
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@
#include "node_subscr.h"

#define TIPC_FLOW_CONTROL_WIN 512
#define CONN_OVERLOAD_LIMIT	((TIPC_FLOW_CONTROL_WIN * 2 + 1) * \
				SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE))

typedef void (*tipc_msg_err_event) (void *usr_handle, u32 portref,
		struct sk_buff **buf, unsigned char const *data,
Loading