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

Commit 7586eceb authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

ipv4: tcp: dont cache output dst for syncookies



Don't cache output dst for syncookies, as this adds pressure on IP route
cache and rcu subsystem for no gain.

Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Hans Schillstrom <hans.schillstrom@ericsson.com>
Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 24ea818e
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ struct flowi_common {
#define FLOWI_FLAG_ANYSRC		0x01
#define FLOWI_FLAG_ANYSRC		0x01
#define FLOWI_FLAG_PRECOW_METRICS	0x02
#define FLOWI_FLAG_PRECOW_METRICS	0x02
#define FLOWI_FLAG_CAN_SLEEP		0x04
#define FLOWI_FLAG_CAN_SLEEP		0x04
#define FLOWI_FLAG_RT_NOCACHE		0x08
	__u32	flowic_secid;
	__u32	flowic_secid;
};
};


+2 −1
Original line number Original line Diff line number Diff line
@@ -251,7 +251,8 @@ extern int inet_csk_get_port(struct sock *sk, unsigned short snum);


extern struct dst_entry* inet_csk_route_req(struct sock *sk,
extern struct dst_entry* inet_csk_route_req(struct sock *sk,
					    struct flowi4 *fl4,
					    struct flowi4 *fl4,
					    const struct request_sock *req);
					    const struct request_sock *req,
					    bool nocache);
extern struct dst_entry* inet_csk_route_child_sock(struct sock *sk,
extern struct dst_entry* inet_csk_route_child_sock(struct sock *sk,
						   struct sock *newsk,
						   struct sock *newsk,
						   const struct request_sock *req);
						   const struct request_sock *req);
+1 −1
Original line number Original line Diff line number Diff line
@@ -504,7 +504,7 @@ static int dccp_v4_send_response(struct sock *sk, struct request_sock *req,
	struct dst_entry *dst;
	struct dst_entry *dst;
	struct flowi4 fl4;
	struct flowi4 fl4;


	dst = inet_csk_route_req(sk, &fl4, req);
	dst = inet_csk_route_req(sk, &fl4, req, false);
	if (dst == NULL)
	if (dst == NULL)
		goto out;
		goto out;


+6 −2
Original line number Original line Diff line number Diff line
@@ -368,17 +368,21 @@ EXPORT_SYMBOL(inet_csk_reset_keepalive_timer);


struct dst_entry *inet_csk_route_req(struct sock *sk,
struct dst_entry *inet_csk_route_req(struct sock *sk,
				     struct flowi4 *fl4,
				     struct flowi4 *fl4,
				     const struct request_sock *req)
				     const struct request_sock *req,
				     bool nocache)
{
{
	struct rtable *rt;
	struct rtable *rt;
	const struct inet_request_sock *ireq = inet_rsk(req);
	const struct inet_request_sock *ireq = inet_rsk(req);
	struct ip_options_rcu *opt = inet_rsk(req)->opt;
	struct ip_options_rcu *opt = inet_rsk(req)->opt;
	struct net *net = sock_net(sk);
	struct net *net = sock_net(sk);
	int flags = inet_sk_flowi_flags(sk) & ~FLOWI_FLAG_PRECOW_METRICS;


	if (nocache)
		flags |= FLOWI_FLAG_RT_NOCACHE;
	flowi4_init_output(fl4, sk->sk_bound_dev_if, sk->sk_mark,
	flowi4_init_output(fl4, sk->sk_bound_dev_if, sk->sk_mark,
			   RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
			   RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
			   sk->sk_protocol,
			   sk->sk_protocol,
			   inet_sk_flowi_flags(sk) & ~FLOWI_FLAG_PRECOW_METRICS,
			   flags,
			   (opt && opt->opt.srr) ? opt->opt.faddr : ireq->rmt_addr,
			   (opt && opt->opt.srr) ? opt->opt.faddr : ireq->rmt_addr,
			   ireq->loc_addr, ireq->rmt_port, inet_sk(sk)->inet_sport);
			   ireq->loc_addr, ireq->rmt_port, inet_sk(sk)->inet_sport);
	security_req_classify_flow(req, flowi4_to_flowi(fl4));
	security_req_classify_flow(req, flowi4_to_flowi(fl4));
+4 −1
Original line number Original line Diff line number Diff line
@@ -1156,7 +1156,7 @@ static struct rtable *rt_intern_hash(unsigned int hash, struct rtable *rt,
	candp = NULL;
	candp = NULL;
	now = jiffies;
	now = jiffies;


	if (!rt_caching(dev_net(rt->dst.dev))) {
	if (!rt_caching(dev_net(rt->dst.dev)) || (rt->dst.flags & DST_NOCACHE)) {
		/*
		/*
		 * If we're not caching, just tell the caller we
		 * If we're not caching, just tell the caller we
		 * were successful and don't touch the route.  The
		 * were successful and don't touch the route.  The
@@ -2582,6 +2582,9 @@ static struct rtable *__mkroute_output(const struct fib_result *res,


	rt_set_nexthop(rth, fl4, res, fi, type, 0);
	rt_set_nexthop(rth, fl4, res, fi, type, 0);


	if (fl4->flowi4_flags & FLOWI_FLAG_RT_NOCACHE)
		rth->dst.flags |= DST_NOCACHE;

	return rth;
	return rth;
}
}


Loading