Skip to content

Commit df5e162

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: conntrack: remove pkt_to_tuple callback
GRE is now builtin, so we can handle it via direct call and remove the callback. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 751fc30 commit df5e162

File tree

5 files changed

+8
-21
lines changed

5 files changed

+8
-21
lines changed

include/linux/netfilter/nf_conntrack_proto_gre.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ void nf_ct_gre_keymap_flush(struct net *net);
3030
/* delete keymap entries */
3131
void nf_ct_gre_keymap_destroy(struct nf_conn *ct);
3232

33+
bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
34+
struct net *net, struct nf_conntrack_tuple *tuple);
3335
#endif /* __KERNEL__ */
3436
#endif /* _CONNTRACK_PROTO_GRE_H */

include/net/netfilter/nf_conntrack_l4proto.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ struct nf_conntrack_l4proto {
2727
/* protoinfo nlattr size, closes a hole */
2828
u16 nlattr_size;
2929

30-
/* Try to fill in the third arg: dataoff is offset past network protocol
31-
hdr. Return true if possible. */
32-
bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int dataoff,
33-
struct net *net, struct nf_conntrack_tuple *tuple);
34-
3530
/* Invert the per-proto part of the tuple: ie. turn xmit into reply.
3631
* Only used by icmp, most protocols use a generic version.
3732
*/

net/netfilter/nf_conntrack_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,11 @@ nf_ct_get_tuple(const struct sk_buff *skb,
279279
return icmpv6_pkt_to_tuple(skb, dataoff, net, tuple);
280280
case IPPROTO_ICMP:
281281
return icmp_pkt_to_tuple(skb, dataoff, net, tuple);
282+
#ifdef CONFIG_NF_CT_PROTO_GRE
283+
case IPPROTO_GRE:
284+
return gre_pkt_to_tuple(skb, dataoff, net, tuple);
285+
#endif
282286
}
283-
if (unlikely(l4proto->pkt_to_tuple))
284-
return l4proto->pkt_to_tuple(skb, dataoff, net, tuple);
285287

286288
/* Actually only need first 4 bytes to get ports. */
287289
inet_hdr = skb_header_pointer(skb, dataoff, sizeof(_inet_hdr), &_inet_hdr);

net/netfilter/nf_conntrack_proto_generic.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ static bool nf_generic_should_process(u8 proto)
2727
}
2828
}
2929

30-
static bool generic_pkt_to_tuple(const struct sk_buff *skb,
31-
unsigned int dataoff,
32-
struct net *net, struct nf_conntrack_tuple *tuple)
33-
{
34-
tuple->src.u.all = 0;
35-
tuple->dst.u.all = 0;
36-
37-
return true;
38-
}
39-
4030
/* Returns verdict for packet, or -1 for invalid. */
4131
static int generic_packet(struct nf_conn *ct,
4232
struct sk_buff *skb,
@@ -149,7 +139,6 @@ static struct nf_proto_net *generic_get_net_proto(struct net *net)
149139
const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic =
150140
{
151141
.l4proto = 255,
152-
.pkt_to_tuple = generic_pkt_to_tuple,
153142
.packet = generic_packet,
154143
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
155144
.ctnl_timeout = {

net/netfilter/nf_conntrack_proto_gre.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ EXPORT_SYMBOL_GPL(nf_ct_gre_keymap_destroy);
162162
/* PUBLIC CONNTRACK PROTO HELPER FUNCTIONS */
163163

164164
/* gre hdr info to tuple */
165-
static bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
166-
struct net *net, struct nf_conntrack_tuple *tuple)
165+
bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
166+
struct net *net, struct nf_conntrack_tuple *tuple)
167167
{
168168
const struct pptp_gre_header *pgrehdr;
169169
struct pptp_gre_header _pgrehdr;
@@ -368,7 +368,6 @@ static int gre_init_net(struct net *net)
368368
/* protocol helper struct */
369369
const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre = {
370370
.l4proto = IPPROTO_GRE,
371-
.pkt_to_tuple = gre_pkt_to_tuple,
372371
#ifdef CONFIG_NF_CONNTRACK_PROCFS
373372
.print_conntrack = gre_print_conntrack,
374373
#endif

0 commit comments

Comments
 (0)