Skip to content

Commit 6b6ec99

Browse files
osctobeDavid S. Miller
authored andcommitted
[NETFILTER]: nfnetlink_log: fix some constants
Fix timeout (one second is 1 * HZ) and convert max packet copy length to #defined constant. Signed-off-by: Michal Miroslaw <mirq-linux@rere.qmqm.pl> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent aace57e commit 6b6ec99

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

net/netfilter/nfnetlink_log.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
#endif
3838

3939
#define NFULNL_NLBUFSIZ_DEFAULT NLMSG_GOODSIZE
40-
#define NFULNL_TIMEOUT_DEFAULT 100 /* every second */
40+
#define NFULNL_TIMEOUT_DEFAULT HZ /* every second */
4141
#define NFULNL_QTHRESH_DEFAULT 100 /* 100 packets */
42+
#define NFULNL_COPY_RANGE_MAX 0xFFFF /* max packet size is limited by 16-bit struct nfattr nfa_len field */
4243

4344
#define PRINTR(x, args...) do { if (net_ratelimit()) \
4445
printk(x, ## args); } while (0);
@@ -171,7 +172,7 @@ instance_create(u_int16_t group_num, int pid)
171172
inst->flushtimeout = NFULNL_TIMEOUT_DEFAULT;
172173
inst->nlbufsiz = NFULNL_NLBUFSIZ_DEFAULT;
173174
inst->copy_mode = NFULNL_COPY_PACKET;
174-
inst->copy_range = 0xffff;
175+
inst->copy_range = NFULNL_COPY_RANGE_MAX;
175176

176177
hlist_add_head(&inst->hlist,
177178
&instance_table[instance_hashfn(group_num)]);
@@ -235,11 +236,8 @@ nfulnl_set_mode(struct nfulnl_instance *inst, u_int8_t mode,
235236

236237
case NFULNL_COPY_PACKET:
237238
inst->copy_mode = mode;
238-
/* we're using struct nlattr which has 16bit nfa_len */
239-
if (range > 0xffff)
240-
inst->copy_range = 0xffff;
241-
else
242-
inst->copy_range = range;
239+
inst->copy_range = min_t(unsigned int,
240+
range, NFULNL_COPY_RANGE_MAX);
243241
break;
244242

245243
default:

0 commit comments

Comments
 (0)