Skip to content

Commit 2d8f648

Browse files
Georg Kohmannkuba-moo
authored andcommitted
ipv6: Remove dependency of ipv6_frag_thdr_truncated on ipv6 module
IPV6=m NF_DEFRAG_IPV6=y ld: net/ipv6/netfilter/nf_conntrack_reasm.o: in function `nf_ct_frag6_gather': net/ipv6/netfilter/nf_conntrack_reasm.c:462: undefined reference to `ipv6_frag_thdr_truncated' Netfilter is depending on ipv6 symbol ipv6_frag_thdr_truncated. This dependency is forcing IPV6=y. Remove this dependency by moving ipv6_frag_thdr_truncated out of ipv6. This is the same solution as used with a similar issues: Referring to commit 70b095c ("ipv6: remove dependency of nf_defrag_ipv6 on ipv6 module") Fixes: 9d9e937 ("ipv6/netfilter: Discard first fragment not including all headers") Reported-by: Randy Dunlap <rdunlap@infradead.org> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Georg Kohmann <geokohma@cisco.com> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org> Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested Link: https://lore.kernel.org/r/20201119095833.8409-1-geokohma@cisco.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent f0b0a2d commit 2d8f648

4 files changed

Lines changed: 32 additions & 33 deletions

File tree

include/net/ipv6.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,6 @@ int ipv6_skip_exthdr(const struct sk_buff *, int start, u8 *nexthdrp,
10641064

10651065
bool ipv6_ext_hdr(u8 nexthdr);
10661066

1067-
bool ipv6_frag_thdr_truncated(struct sk_buff *skb, int start, u8 *nexthdrp);
1068-
10691067
enum {
10701068
IP6_FH_F_FRAG = (1 << 0),
10711069
IP6_FH_F_AUTH = (1 << 1),

include/net/ipv6_frag.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,35 @@ ip6frag_expire_frag_queue(struct net *net, struct frag_queue *fq)
108108
rcu_read_unlock();
109109
inet_frag_put(&fq->q);
110110
}
111+
112+
/* Check if the upper layer header is truncated in the first fragment. */
113+
static inline bool
114+
ipv6frag_thdr_truncated(struct sk_buff *skb, int start, u8 *nexthdrp)
115+
{
116+
u8 nexthdr = *nexthdrp;
117+
__be16 frag_off;
118+
int offset;
119+
120+
offset = ipv6_skip_exthdr(skb, start, &nexthdr, &frag_off);
121+
if (offset < 0 || (frag_off & htons(IP6_OFFSET)))
122+
return false;
123+
switch (nexthdr) {
124+
case NEXTHDR_TCP:
125+
offset += sizeof(struct tcphdr);
126+
break;
127+
case NEXTHDR_UDP:
128+
offset += sizeof(struct udphdr);
129+
break;
130+
case NEXTHDR_ICMP:
131+
offset += sizeof(struct icmp6hdr);
132+
break;
133+
default:
134+
offset += 1;
135+
}
136+
if (offset > skb->len)
137+
return true;
138+
return false;
139+
}
140+
111141
#endif
112142
#endif

net/ipv6/netfilter/nf_conntrack_reasm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
459459
/* Discard the first fragment if it does not include all headers
460460
* RFC 8200, Section 4.5
461461
*/
462-
if (ipv6_frag_thdr_truncated(skb, fhoff, &nexthdr)) {
462+
if (ipv6frag_thdr_truncated(skb, fhoff, &nexthdr)) {
463463
pr_debug("Drop incomplete fragment\n");
464464
return 0;
465465
}

net/ipv6/reassembly.c

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -318,35 +318,6 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *skb,
318318
return -1;
319319
}
320320

321-
/* Check if the upper layer header is truncated in the first fragment. */
322-
bool ipv6_frag_thdr_truncated(struct sk_buff *skb, int start, u8 *nexthdrp)
323-
{
324-
u8 nexthdr = *nexthdrp;
325-
__be16 frag_off;
326-
int offset;
327-
328-
offset = ipv6_skip_exthdr(skb, start, &nexthdr, &frag_off);
329-
if (offset < 0 || (frag_off & htons(IP6_OFFSET)))
330-
return false;
331-
switch (nexthdr) {
332-
case NEXTHDR_TCP:
333-
offset += sizeof(struct tcphdr);
334-
break;
335-
case NEXTHDR_UDP:
336-
offset += sizeof(struct udphdr);
337-
break;
338-
case NEXTHDR_ICMP:
339-
offset += sizeof(struct icmp6hdr);
340-
break;
341-
default:
342-
offset += 1;
343-
}
344-
if (offset > skb->len)
345-
return true;
346-
return false;
347-
}
348-
EXPORT_SYMBOL(ipv6_frag_thdr_truncated);
349-
350321
static int ipv6_frag_rcv(struct sk_buff *skb)
351322
{
352323
struct frag_hdr *fhdr;
@@ -390,7 +361,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
390361
* the source of the fragment, with the Pointer field set to zero.
391362
*/
392363
nexthdr = hdr->nexthdr;
393-
if (ipv6_frag_thdr_truncated(skb, skb_transport_offset(skb), &nexthdr)) {
364+
if (ipv6frag_thdr_truncated(skb, skb_transport_offset(skb), &nexthdr)) {
394365
__IP6_INC_STATS(net, __in6_dev_get_safely(skb->dev),
395366
IPSTATS_MIB_INHDRERRORS);
396367
icmpv6_param_prob(skb, ICMPV6_HDR_INCOMP, 0);

0 commit comments

Comments
 (0)