net: Split sk_no_check into sk_no_check_{rx,tx}
authorTom Herbert <therbert@google.com>
Fri, 23 May 2014 15:47:19 +0000 (08:47 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 23 May 2014 20:28:53 +0000 (16:28 -0400)
Define separate fields in the sock structure for configuring disabling
checksums in both TX and RX-- sk_no_check_tx and sk_no_check_rx.
The SO_NO_CHECK socket option only affects sk_no_check_tx. Also,
removed UDP_CSUM_* defines since they are no longer necessary.

Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
13 files changed:
drivers/scsi/iscsi_tcp.c
include/net/sock.h
include/net/udp.h
net/appletalk/ddp.c
net/core/sock.c
net/decnet/af_decnet.c
net/ipv4/udp.c
net/ipv6/udp.c
net/ipx/af_ipx.c
net/ipx/ipx_route.c
net/l2tp/l2tp_core.c
net/l2tp/l2tp_netlink.c
net/sctp/socket.c

index 11854845393bf9cc13688ff3895339997822fa61..a669f2d11c314e380eb2aa90714b91eb0064f781 100644 (file)
@@ -244,7 +244,7 @@ iscsi_sw_tcp_conn_restore_callbacks(struct iscsi_conn *conn)
        sk->sk_data_ready   = tcp_sw_conn->old_data_ready;
        sk->sk_state_change = tcp_sw_conn->old_state_change;
        sk->sk_write_space  = tcp_sw_conn->old_write_space;
-       sk->sk_no_check  = 0;
+       sk->sk_no_check_tx = 0;
        write_unlock_bh(&sk->sk_callback_lock);
 }
 
index 21569cf456ed54459a537e5a6cf02349a2a8413c..07b7fcd60d808a33f9e6fff208c07fe412da8c7e 100644 (file)
@@ -243,7 +243,8 @@ struct cg_proto;
   *    @sk_sndbuf: size of send buffer in bytes
   *    @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE,
   *               %SO_OOBINLINE settings, %SO_TIMESTAMPING settings
-  *    @sk_no_check: %SO_NO_CHECK setting, whether or not checkup packets
+  *    @sk_no_check_tx: %SO_NO_CHECK setting, set checksum in TX packets
+  *    @sk_no_check_rx: allow zero checksum in RX packets
   *    @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
   *    @sk_route_nocaps: forbidden route capabilities (e.g NETIF_F_GSO_MASK)
   *    @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)
@@ -371,7 +372,8 @@ struct sock {
        struct sk_buff_head     sk_write_queue;
        kmemcheck_bitfield_begin(flags);
        unsigned int            sk_shutdown  : 2,
-                               sk_no_check  : 2,
+                               sk_no_check_tx : 1,
+                               sk_no_check_rx : 1,
                                sk_userlocks : 4,
                                sk_protocol  : 8,
                                sk_type      : 16;
index a24f0f3e107f67c71b256cd4fb85d04b2389fb7a..5eb86874bcd68bc5b5d1c0069db35411b0573b85 100644 (file)
@@ -95,15 +95,6 @@ static inline struct udp_hslot *udp_hashslot2(struct udp_table *table,
        return &table->hash2[hash & table->mask];
 }
 
-/* Note: this must match 'valbool' in sock_setsockopt */
-#define UDP_CSUM_NOXMIT                1
-
-/* Used by SunRPC/xprt layer. */
-#define UDP_CSUM_NORCV         2
-
-/* Default, as per the RFC, is to always do csums. */
-#define UDP_CSUM_DEFAULT       0
-
 extern struct proto udp_prot;
 
 extern atomic_long_t udp_memory_allocated;
index 786ee2f83d5fea1dbfd6bb2660544d7f88e1eff2..01a1082e02b3157b3abc84e6b23844ed3a26f2f2 100644 (file)
@@ -1669,7 +1669,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
                goto out;
        }
 
-       if (sk->sk_no_check == 1)
+       if (sk->sk_no_check_tx)
                ddp->deh_sum = 0;
        else
                ddp->deh_sum = atalk_checksum(skb, len + sizeof(*ddp));
index 664ee4295b6f6ec38fb4f89d11c52eaa383a15d1..026e01f70274f8a5550af6a7a06fd6846735e4ae 100644 (file)
@@ -784,7 +784,7 @@ set_rcvbuf:
                break;
 
        case SO_NO_CHECK:
-               sk->sk_no_check = valbool;
+               sk->sk_no_check_tx = valbool;
                break;
 
        case SO_PRIORITY:
@@ -1064,7 +1064,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                break;
 
        case SO_NO_CHECK:
-               v.val = sk->sk_no_check;
+               v.val = sk->sk_no_check_tx;
                break;
 
        case SO_PRIORITY:
index 4c04848953bdb4caddeae9debd195ea3d004ee0d..ae011b46c0710fc96204deda6bddb1d912d78f22 100644 (file)
@@ -481,7 +481,7 @@ static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gf
 
        sk->sk_backlog_rcv = dn_nsp_backlog_rcv;
        sk->sk_destruct    = dn_destruct;
-       sk->sk_no_check    = 1;
+       sk->sk_no_check_tx = 1;
        sk->sk_family      = PF_DECnet;
        sk->sk_protocol    = 0;
        sk->sk_allocation  = gfp;
index 590532a7bd2d39c582f95d47abba30e45cdbddfe..12c6175b29cd073c90ddc5f08b5d772315aedaee 100644 (file)
@@ -785,7 +785,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4)
        if (is_udplite)                                  /*     UDP-Lite      */
                csum = udplite_csum(skb);
 
-       else if (sk->sk_no_check == UDP_CSUM_NOXMIT) {   /* UDP csum disabled */
+       else if (sk->sk_no_check_tx) {   /* UDP csum disabled */
 
                skb->ip_summed = CHECKSUM_NONE;
                goto send;
index c7ed47bde54b33f66566b3de1d0284b64906decf..b8db453133aae0946f29aac219620c8bae0cd8ca 100644 (file)
@@ -797,7 +797,7 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
                /* If zero checksum and sk_no_check is not on for
                 * the socket then skip it.
                 */
-               if (uh->check || sk->sk_no_check)
+               if (uh->check || sk->sk_no_check_rx)
                        stack[count++] = sk;
 
                sk = udp_v6_mcast_next(net, sk_nulls_next(sk), uh->dest, daddr,
@@ -887,7 +887,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
        if (sk != NULL) {
                int ret;
 
-               if (!uh->check && !sk->sk_no_check) {
+               if (!uh->check && !sk->sk_no_check_rx) {
                        sock_put(sk);
                        udp6_csum_zero_error(skb);
                        goto csum_error;
@@ -1037,7 +1037,7 @@ static int udp_v6_push_pending_frames(struct sock *sk)
 
        if (is_udplite)
                csum = udplite_csum_outgoing(sk, skb);
-       else if (sk->sk_no_check == UDP_CSUM_NOXMIT) {   /* UDP csum disabled */
+       else if (sk->sk_no_check_tx) {   /* UDP csum disabled */
                skb->ip_summed = CHECKSUM_NONE;
                goto send;
        } else if (skb->ip_summed == CHECKSUM_PARTIAL) { /* UDP hardware csum */
index 41e4e93cb3aae37df41ff419ef34be9c2255b5cc..91729b807c7d041ae379e89df335acefe5218635 100644 (file)
@@ -1353,7 +1353,7 @@ static int ipx_create(struct net *net, struct socket *sock, int protocol,
 
        sk_refcnt_debug_inc(sk);
        sock_init_data(sock, sk);
-       sk->sk_no_check = 1;            /* Checksum off by default */
+       sk->sk_no_check_tx = 1;         /* Checksum off by default */
        sock->ops = &ipx_dgram_ops;
        rc = 0;
 out:
index c1f03185c5e115ffe359e39a0bfb17efe8d4c38a..67e7ad3d46b1fb4489a175836351607e7f5ae741 100644 (file)
@@ -236,7 +236,8 @@ int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
        }
 
        /* Apply checksum. Not allowed on 802.3 links. */
-       if (sk->sk_no_check || intrfc->if_dlink_type == htons(IPX_FRAME_8023))
+       if (sk->sk_no_check_tx ||
+           intrfc->if_dlink_type == htons(IPX_FRAME_8023))
                ipx->ipx_checksum = htons(0xFFFF);
        else
                ipx->ipx_checksum = ipx_cksum(ipx, len + sizeof(struct ipxhdr));
index ed0716a075ba928f5d4c8942eeed9839d3389f3f..a1186105f53739401c437dee964e965779419204 100644 (file)
@@ -1188,7 +1188,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
                        l2tp_xmit_ipv6_csum(sk, skb, udp_len);
                else
 #endif
-               if (sk->sk_no_check == UDP_CSUM_NOXMIT)
+               if (sk->sk_no_check_tx)
                        skb->ip_summed = CHECKSUM_NONE;
                else if ((skb_dst(skb) && skb_dst(skb)->dev) &&
                         (!(skb_dst(skb)->dev->features & NETIF_F_V4_CSUM))) {
@@ -1463,7 +1463,7 @@ static int l2tp_tunnel_sock_create(struct net *net,
                }
 
                if (!cfg->use_udp_checksums)
-                       sock->sk->sk_no_check = UDP_CSUM_NOXMIT;
+                       sock->sk->sk_no_check_tx = 1;
 
                break;
 
index bd7387adea9eff25ce7ffd0683589dcdcc020ad0..f3d331bdd7062b27312e827a31db816f701b5f7d 100644 (file)
@@ -297,8 +297,7 @@ static int l2tp_nl_tunnel_send(struct sk_buff *skb, u32 portid, u32 seq, int fla
        case L2TP_ENCAPTYPE_UDP:
                if (nla_put_u16(skb, L2TP_ATTR_UDP_SPORT, ntohs(inet->inet_sport)) ||
                    nla_put_u16(skb, L2TP_ATTR_UDP_DPORT, ntohs(inet->inet_dport)) ||
-                   nla_put_u8(skb, L2TP_ATTR_UDP_CSUM,
-                              (sk->sk_no_check != UDP_CSUM_NOXMIT)))
+                   nla_put_u8(skb, L2TP_ATTR_UDP_CSUM, !sk->sk_no_check_tx))
                        goto nla_put_failure;
                /* NOBREAK */
        case L2TP_ENCAPTYPE_IP:
index 2af76eaba8f784e4d7b4276c8c2ef46b1ef30925..429899689408caec64cf5c36b4eb0b00369f8e48 100644 (file)
@@ -6946,7 +6946,8 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
        newsk->sk_type = sk->sk_type;
        newsk->sk_bound_dev_if = sk->sk_bound_dev_if;
        newsk->sk_flags = sk->sk_flags;
-       newsk->sk_no_check = sk->sk_no_check;
+       newsk->sk_no_check_tx = sk->sk_no_check_tx;
+       newsk->sk_no_check_rx = sk->sk_no_check_rx;
        newsk->sk_reuse = sk->sk_reuse;
 
        newsk->sk_shutdown = sk->sk_shutdown;
This page took 0.034164 seconds and 5 git commands to generate.