net: Pre-COW metrics for TCP.
TCP is going to record metrics for the connection, so pre-COW the route metrics at route cache entry creation time. This avoids several atomic operations that have to occur if we COW the metrics after the entry reaches global visibility. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -48,7 +48,8 @@ struct flowi {
|
||||
|
||||
__u8 proto;
|
||||
__u8 flags;
|
||||
#define FLOWI_FLAG_ANYSRC 0x01
|
||||
#define FLOWI_FLAG_ANYSRC 0x01
|
||||
#define FLOWI_FLAG_PRECOW_METRICS 0x02
|
||||
union {
|
||||
struct {
|
||||
__be16 sport;
|
||||
|
||||
@@ -219,7 +219,13 @@ static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops
|
||||
|
||||
static inline __u8 inet_sk_flowi_flags(const struct sock *sk)
|
||||
{
|
||||
return inet_sk(sk)->transparent ? FLOWI_FLAG_ANYSRC : 0;
|
||||
__u8 flags = 0;
|
||||
|
||||
if (inet_sk(sk)->transparent)
|
||||
flags |= FLOWI_FLAG_ANYSRC;
|
||||
if (sk->sk_protocol == IPPROTO_TCP)
|
||||
flags |= FLOWI_FLAG_PRECOW_METRICS;
|
||||
return flags;
|
||||
}
|
||||
|
||||
#endif /* _INET_SOCK_H */
|
||||
|
||||
@@ -182,6 +182,8 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
|
||||
|
||||
if (inet_sk(sk)->transparent)
|
||||
fl.flags |= FLOWI_FLAG_ANYSRC;
|
||||
if (protocol == IPPROTO_TCP)
|
||||
fl.flags |= FLOWI_FLAG_PRECOW_METRICS;
|
||||
|
||||
if (!dst || !src) {
|
||||
err = __ip_route_output_key(net, rp, &fl);
|
||||
@@ -209,6 +211,8 @@ static inline int ip_route_newports(struct rtable **rp, u8 protocol,
|
||||
fl.proto = protocol;
|
||||
if (inet_sk(sk)->transparent)
|
||||
fl.flags |= FLOWI_FLAG_ANYSRC;
|
||||
if (protocol == IPPROTO_TCP)
|
||||
fl.flags |= FLOWI_FLAG_PRECOW_METRICS;
|
||||
ip_rt_put(*rp);
|
||||
*rp = NULL;
|
||||
security_sk_classify_flow(sk, &fl);
|
||||
|
||||
Reference in New Issue
Block a user