summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2015-08-07 09:47:15 +0200
committerTobias Klauser <tklauser@distanz.ch>2015-08-07 09:47:15 +0200
commit890aea491bd4326a5d03adba92495e4722a6b63e (patch)
tree2635f5a8ae63080bbe23a2f0c63e04a0cac8c200
parent841bfc6b2b195f0263c1a147e7cac2416eb50916 (diff)
flowtop: Simplify nfct_is_dns()
Instead of creating an additional struct flow_entry on the stack just to use the CP_NFCT macros, call nfct_get_attr_u16() directly. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--flowtop.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/flowtop.c b/flowtop.c
index 9cc7302..d988590 100644
--- a/flowtop.c
+++ b/flowtop.c
@@ -205,8 +205,6 @@ static void signal_handler(int number)
static void flow_entry_from_ct(struct flow_entry *n, struct nf_conntrack *ct);
static void flow_entry_get_extended(struct flow_entry *n);
-static bool nfct_is_dns(struct nf_conntrack *ct);
-
static void help(void)
{
printf("flowtop %s, top-like netfilter TCP/UDP/SCTP/.. flow tracking\n",
@@ -264,6 +262,14 @@ static inline void flow_list_init(struct flow_list *fl)
spinlock_init(&fl->lock);
}
+static inline bool nfct_is_dns(struct nf_conntrack *ct)
+{
+ uint16_t port_src = nfct_get_attr_u16(ct, ATTR_ORIG_PORT_SRC);
+ uint16_t port_dst = nfct_get_attr_u16(ct, ATTR_ORIG_PORT_DST);
+
+ return ntohs(port_src) == 53 || ntohs(port_dst) == 53;
+}
+
static void flow_list_new_entry(struct flow_list *fl, struct nf_conntrack *ct)
{
struct flow_entry *n;
@@ -532,17 +538,6 @@ enum flow_entry_direction {
flow_entry_dst,
};
-static bool nfct_is_dns(struct nf_conntrack *ct)
-{
- struct flow_entry fl;
- struct flow_entry *n = &fl;
-
- CP_NFCT(port_src, ATTR_ORIG_PORT_SRC, 16);
- CP_NFCT(port_dst, ATTR_ORIG_PORT_DST, 16);
-
- return ntohs(n->port_src) == 53 || ntohs(n->port_dst) == 53;
-}
-
#define SELFLD(dir,src_member,dst_member) \
(((dir) == flow_entry_src) ? n->src_member : n->dst_member)