History

net: use sk_is_tcp() in more places

Move sk_is_tcp() to include/net/sock.h and use it where we can.

Eric Dumazet committed 5 years ago

Commit 42f67ee1 parent 37354404 files · +9 −14Browse files

Unified · Split

4 files
  1. include/linux/skmsg.h +0 −6
  2. include/net/sock.h +5 −0
  3. net/core/skbuff.c +2 −4
  4. net/core/sock.c +2 −4
include/linux/skmsg.h+0−6
@@ -507,12 +507,6 @@ static inline bool sk_psock_strp_enabled(struct sk_psock *psock) · 506 unmodified lines
507 return !!psock->saved_data_ready;507 return !!psock->saved_data_ready;
508}508}
509 509
510static inline bool sk_is_tcp(const struct sock *sk)
511{
512 return sk->sk_type == SOCK_STREAM &&
513 sk->sk_protocol == IPPROTO_TCP;
514}
515
516static inline bool sk_is_udp(const struct sock *sk)510static inline bool sk_is_udp(const struct sock *sk)
517{511{
518 return sk->sk_type == SOCK_DGRAM &&512 return sk->sk_type == SOCK_DGRAM &&
include/net/sock.h+5−0
@@ -2638,6 +2638,11 @@ static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u16 tsflags) · 2637 unmodified lines
2638 &skb_shinfo(skb)->tskey);2638 &skb_shinfo(skb)->tskey);
2639}2639}
2640 2640
2641static inline bool sk_is_tcp(const struct sock *sk)
2642{
2643 return sk->sk_type == SOCK_STREAM && sk->sk_protocol == IPPROTO_TCP;
2644}
2645
2641/**2646/**
2642 * sk_eat_skb - Release a skb if it is no longer needed2647 * sk_eat_skb - Release a skb if it is no longer needed
2643 * @sk: socket to eat this skb from2648 * @sk: socket to eat this skb from
net/core/skbuff.c+2−4
@@ -4849,8 +4849,7 @@ static void __skb_complete_tx_timestamp(struct sk_buff *skb, · 4848 unmodified lines
4849 serr->header.h4.iif = skb->dev ? skb->dev->ifindex : 0;4849 serr->header.h4.iif = skb->dev ? skb->dev->ifindex : 0;
4850 if (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID) {4850 if (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID) {
4851 serr->ee.ee_data = skb_shinfo(skb)->tskey;4851 serr->ee.ee_data = skb_shinfo(skb)->tskey;
4852 if (sk->sk_protocol == IPPROTO_TCP &&4852 if (sk_is_tcp(sk))
4853 sk->sk_type == SOCK_STREAM)
4854 serr->ee.ee_data -= sk->sk_tskey;4853 serr->ee.ee_data -= sk->sk_tskey;
4855 }4854 }
4856 4855
@@ -4919,8 +4918,7 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb, · 62 unmodified lines
4919 if (tsonly) {4918 if (tsonly) {
4920#ifdef CONFIG_INET4919#ifdef CONFIG_INET
4921 if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_STATS) &&4920 if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_STATS) &&
4922 sk->sk_protocol == IPPROTO_TCP &&4921 sk_is_tcp(sk)) {
4923 sk->sk_type == SOCK_STREAM) {
4924 skb = tcp_get_timestamping_opt_stats(sk, orig_skb,4922 skb = tcp_get_timestamping_opt_stats(sk, orig_skb,
4925 ack_skb);4923 ack_skb);
4926 opt_stats = true;4924 opt_stats = true;
net/core/sock.c+2−4
@@ -872,8 +872,7 @@ int sock_set_timestamping(struct sock *sk, int optname, · 871 unmodified lines
872 872
873 if (val & SOF_TIMESTAMPING_OPT_ID &&873 if (val & SOF_TIMESTAMPING_OPT_ID &&
874 !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) {874 !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) {
875 if (sk->sk_protocol == IPPROTO_TCP &&875 if (sk_is_tcp(sk)) {
876 sk->sk_type == SOCK_STREAM) {
877 if ((1 << sk->sk_state) &876 if ((1 << sk->sk_state) &
878 (TCPF_CLOSE | TCPF_LISTEN))877 (TCPF_CLOSE | TCPF_LISTEN))
879 return -EINVAL;878 return -EINVAL;
@@ -1370,8 +1369,7 @@ set_sndbuf: · 490 unmodified lines
1370 1369
1371 case SO_ZEROCOPY:1370 case SO_ZEROCOPY:
1372 if (sk->sk_family == PF_INET || sk->sk_family == PF_INET6) {1371 if (sk->sk_family == PF_INET || sk->sk_family == PF_INET6) {
1373 if (!((sk->sk_type == SOCK_STREAM &&1372 if (!(sk_is_tcp(sk) ||
1374 sk->sk_protocol == IPPROTO_TCP) ||
1375 (sk->sk_type == SOCK_DGRAM &&1373 (sk->sk_type == SOCK_DGRAM &&
1376 sk->sk_protocol == IPPROTO_UDP)))1374 sk->sk_protocol == IPPROTO_UDP)))
1377 ret = -ENOTSUPP;1375 ret = -ENOTSUPP;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t