Skip to contentSkip to conversation

LOG and DROP some specified packets in the same iptables rule

PATCH Vincent 2 participants 4 messages May 2, 2005 netfilter

lore
Share & tools
lore

Vincent

author
#0 lore raw

Hello,

If I would like to log and drop some specified packets in the same iptables rule.
Can I simply do the change in ipt_LOG.c like the following.

ipt_LOG.c 2005-05-02 12:58:45.000000000 +0800 renamed from ipt_LOG.c.old 2005-05-02 12:58:18.000000000 +0800 +1 -1
@@ -346,7 +346,7 @@ ipt_log_target(struct sk_buff **pskb,
        printk("\n");
        spin_unlock_bh(&log_lock);
 
-       return IPT_CONTINUE;
+       return NF_DROP;
 }
 
 static int ipt_log_checkentry(const char *tablename,

Will this change cause any side effect that I don't know? Thanks in advance.

Vincent

#1 lore raw
Quoted 12 lines

Can I simply do the change in ipt_LOG.c like the following.

ipt_LOG.c 2005-05-02 12:58:45.000000000 +0800 renamed from ipt_LOG.c.old 2005-05-02 12:58:18.000000000 +0800 +1 -1
@@ -346,7 +346,7 @@ ipt_log_target(struct sk_buff **pskb,
        printk("\n");
        spin_unlock_bh(&log_lock);
 
-       return IPT_CONTINUE;
+       return NF_DROP;
 }
 
Quoted 1 line

Will this change cause any side effect that I don't know?

If you do this privately, I don't think so.

Of course, nobody would take such a patch from you, as it breaks compatibility with each and every LOG using ruleset in current use.

best regards
Patrick

author
#2 lore raw
Quoted 12 lines
Quoted 12 lines

Can I simply do the change in ipt_LOG.c like the following.

ipt_LOG.c 2005-05-02 12:58:45.000000000 +0800 renamed from ipt_LOG.c.old 2005-05-02 12:58:18.000000000 +0800 +1 -1
@@ -346,7 +346,7 @@ ipt_log_target(struct sk_buff **pskb,
        printk("\n");
        spin_unlock_bh(&log_lock);
 
-       return IPT_CONTINUE;
+       return NF_DROP;
 }
 
Quoted 8 lines
Quoted 1 line

Will this change cause any side effect that I don't know?

If you do this privately, I don't think so.

Of course, nobody would take such a patch from you, as it breaks compatibility with each and every LOG using ruleset in current use.

Yes, I would do the changes and rename the module (ex. DLOG) for incompatibility.
When I want to log and then drop the specified packets, I can write like the following
iptables rule to reduce the amounts of rule number for performance improvement in the system.
Do you think so?

iptables -t mangle -A FORWARD -p udp --dport 1024: -j DLOG --log-prefix "Drop this packet "

Vincent

#3 lore raw
Quoted 5 lines

When I want to log and then drop the specified packets, I can write like the following
iptables rule to reduce the amounts of rule number for performance improvement in the system.
Do you think so?

If all you want to have is performance optimization in the number of rules, you can easily use the "traditional" approach of a user defined LOGDROP chain:

iptables -t mangle -N LOGDROP
iptables -t mangle -A LOGDROP -j LOG --log-prefix "LOGDROP: " iptables -t mangle -A LOGDROP -j DROP

Quoted 2 lines

iptables -t mangle -A FORWARD -p udp --dport 1024: -j DLOG --log-prefix "Drop this packet "

then becomes

iptables -t mangle -A FORWARD -p udp --dport 1024: -j LOGDROP

as often as you need it.

Drawback: now the --log-prefix is the same for all callers of LOGDROP.

I wouldn't go to the effort of locally making a copy of LOG, like the DLOG you propose. It would make more sense, if people agree that this is a generally useful approach, to make a (hopefully backwards compatible) new option to LOG, called --drop.

Of course, the general solution, which has been talked about a lot, but never really reached the point of being incorporated, is to be able to have multiple targets in the same rule line.

The last time we had this discussion, was about one or two weeks ago. :)

best regards
Patrick