Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01435b2e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

ANDROID: GKI: net: add vendor hooks for 'struct nf_conn' lifecycle



Some vendors want to add a field when a 'sruct nf_conn' is added so give a
hook to handle this.  Any memory allocated when
trace_android_rvh_nf_conn_alloc() is called needs to be freed when
trace_android_rvh_nf_conn_free() is called.

Note, if trace_android_rvh_nf_conn_alloc() fails, be sure to be able to
handle this in trace_android_rvh_nf_conn_free(), but that should not be
an issue as that needs to be addressed in vendor code that runs for
'struct nf_conn' objects that have been created before the vendor code
is loaded no matter what.

Bug: 171013716
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
Change-Id: I67a9be129150690f8c1961accf7d5cdf0d5d50cc
parent 0bc7257c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ptype_head);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kfree_skb);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sk_alloc);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sk_free);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_nf_conn_alloc);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_nf_conn_free);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_arch_set_freq_scale);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_set_priority);
+8 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@ struct packet_type;
struct list_head;
struct sk_buff;
struct sock;
struct nf_conn;

DECLARE_HOOK(android_vh_ptype_head,
	TP_PROTO(const struct packet_type *pt, struct list_head *vendor_pt),
	TP_ARGS(pt, vendor_pt));
@@ -23,11 +25,17 @@ DECLARE_RESTRICTED_HOOK(android_rvh_sk_alloc,
	TP_PROTO(struct sock *sock), TP_ARGS(sock), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_sk_free,
	TP_PROTO(struct sock *sock), TP_ARGS(sock), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_nf_conn_alloc,
	TP_PROTO(struct nf_conn *nf_conn), TP_ARGS(nf_conn), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_nf_conn_free,
	TP_PROTO(struct nf_conn *nf_conn), TP_ARGS(nf_conn), 1);
#else
#define trace_android_vh_ptype_head(pt, vendor_pt)
#define trace_android_vh_kfree_skb(skb)
#define trace_android_rvh_sk_alloc(sock)
#define trace_android_rvh_sk_free(sock)
#define trace_android_rvh_sk_alloc(nf_conn)
#define trace_android_rvh_sk_free(nf_conn)
#endif
#endif /* _TRACE_HOOK_NET_VH_H */
/* This part must be outside protection */
+4 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <linux/mm.h>
#include <linux/nsproxy.h>
#include <linux/rculist_nulls.h>
#include <trace/hooks/net.h>

#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_l4proto.h>
@@ -1387,6 +1388,8 @@ __nf_conntrack_alloc(struct net *net,

	nf_ct_zone_add(ct, zone);

	trace_android_rvh_nf_conn_alloc(ct);

	/* Because we use RCU lookups, we set ct_general.use to zero before
	 * this is inserted in any list.
	 */
@@ -1420,6 +1423,7 @@ void nf_conntrack_free(struct nf_conn *ct)
	nf_ct_ext_free(ct);
	kmem_cache_free(nf_conntrack_cachep, ct);
	smp_mb__before_atomic();
	trace_android_rvh_nf_conn_free(ct);
	atomic_dec(&net->ct.count);
}
EXPORT_SYMBOL_GPL(nf_conntrack_free);