@@ -1157,8 +1157,21 @@ void ipv6_push_nfrag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt,
void ipv6_push_frag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt,
u8 *proto);
-int ipv6_skip_exthdr(const struct sk_buff *, int start, u8 *nexthdrp,
- __be16 *frag_offp);
+int __ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
+ __be16 *frag_offp, bool no_rthdr);
+
+static inline int ipv6_skip_exthdr(const struct sk_buff *skb, int start,
+ u8 *nexthdrp, __be16 *frag_offp)
+{
+ return __ipv6_skip_exthdr(skb, start, nexthdrp, frag_offp, false);
+}
+
+static inline int ipv6_skip_exthdr_no_rthdr(const struct sk_buff *skb,
+ int start, u8 *nexthdrp,
+ __be16 *frag_offp)
+{
+ return __ipv6_skip_exthdr(skb, start, nexthdrp, frag_offp, true);
+}
bool ipv6_ext_hdr(u8 nexthdr);
@@ -69,8 +69,8 @@ EXPORT_SYMBOL(ipv6_ext_hdr);
* --ANK (980726)
*/
-int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
- __be16 *frag_offp)
+int __ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
+ __be16 *frag_offp, bool no_rthdr)
{
u8 nexthdr = *nexthdrp;
@@ -85,7 +85,8 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr);
if (!hp)
return -1;
- if (nexthdr == NEXTHDR_FRAGMENT) {
+ switch (nexthdr) {
+ case NEXTHDR_FRAGMENT: {
__be16 _frag_off, *fp;
fp = skb_header_pointer(skb,
start+offsetof(struct frag_hdr,
@@ -97,21 +98,31 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
*frag_offp = *fp;
if (ntohs(*frag_offp) & ~0x7)
- break;
+ goto out;
hdrlen = 8;
- } else if (nexthdr == NEXTHDR_AUTH)
+ break;
+ }
+ case NEXTHDR_AUTH:
hdrlen = ipv6_authlen(hp);
- else
+ break;
+ case NEXTHDR_ROUTING:
+ if (no_rthdr)
+ return -1;
+ fallthrough;
+ default:
hdrlen = ipv6_optlen(hp);
+ break;
+ }
nexthdr = hp->nexthdr;
start += hdrlen;
}
+out:
*nexthdrp = nexthdr;
return start;
}
-EXPORT_SYMBOL(ipv6_skip_exthdr);
+EXPORT_SYMBOL(__ipv6_skip_exthdr);
int ipv6_find_tlv(const struct sk_buff *skb, int offset, int type)
{
ipv6_skip_exthdr_no_rthdr will be called by drivers that support protocol specific transmit checksum offload with extension headers. Protocol specific checksum offload doesn't work with routing headers since the destination address in the IPv6 header is not the one used in the pseduo checksum for TCP or UDP. This is not a problem with protocol agnostic checksum offload. If a routing header is present then ipv6_skip_exthdr_no_rthdr returns a value less than zero, this is an indication that the driver should call skb_checksum_help instead of offloading the checksum which would be doomed to cause a packet drop at the receiver due to a bad checksum. Signed-off-by: Tom Herbert <tom@herbertland.com> --- include/net/ipv6.h | 17 +++++++++++++++-- net/ipv6/exthdrs_core.c | 25 ++++++++++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-)