Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _NF_REJECT_H
0003 #define _NF_REJECT_H
0004 
0005 #include <linux/types.h>
0006 #include <uapi/linux/in.h>
0007 
0008 static inline bool nf_reject_verify_csum(struct sk_buff *skb, int dataoff,
0009                       __u8 proto)
0010 {
0011     /* Skip protocols that don't use 16-bit one's complement checksum
0012      * of the entire payload.
0013      */
0014     switch (proto) {
0015         /* Protocols with optional checksums. */
0016         case IPPROTO_UDP: {
0017             const struct udphdr *udp_hdr;
0018             struct udphdr _udp_hdr;
0019 
0020             udp_hdr = skb_header_pointer(skb, dataoff,
0021                              sizeof(_udp_hdr),
0022                              &_udp_hdr);
0023             if (!udp_hdr || udp_hdr->check)
0024                 return true;
0025 
0026             return false;
0027         }
0028         case IPPROTO_GRE:
0029 
0030         /* Protocols with other integrity checks. */
0031         case IPPROTO_AH:
0032         case IPPROTO_ESP:
0033         case IPPROTO_SCTP:
0034 
0035         /* Protocols with partial checksums. */
0036         case IPPROTO_UDPLITE:
0037         case IPPROTO_DCCP:
0038             return false;
0039     }
0040     return true;
0041 }
0042 
0043 #endif /* _NF_REJECT_H */