All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fwd: ACCEPT/DROP]
@ 2002-12-20 13:54 Venkatesh Prasad Ranganath
  2002-12-21 14:12 ` Markus Schaber
  0 siblings, 1 reply; 6+ messages in thread
From: Venkatesh Prasad Ranganath @ 2002-12-20 13:54 UTC (permalink / raw)
  To: netfilter-devel



Hi,

I was looking into the iptables implementation and was intrigued about 
how iptables would handle a situation in which we have identical rules 
except for their targets which are contradicting, say ACCEPT and DROP. 
 By looking at ipt_do_table() function it seems that the first 
non-IPT_RETURN  verdict from any standard target will end the traversal 
of a chain of a table, which seems to be a bit odd.  First, such 
conflicting rules must not be allowed.  Even beyond, this fails in the 
situation where you have a dropping rule added after an accepting rule.

For example, a packet from m.n.o.p to a.b.c.d would be accepted at 
a.b.c.d because of the first rule, although it had to be dropped 
according to the second rule.   And this would result because of the 
order in which the rules are added to the table.

iptables -A INPUT -d a.b.c.d -j ACCEPT
iptables -A INPUT -s m.n.o.p -j DROP

Is my understanding correct?  If so, I am curious to know how nf-hipac 
behaves in such situations?

waiting for reply,

-- 

Venkatesh Prasad Ranganath,
Dept. Computing and Information Science,
Kansas State University, US.
web: http://www.cis.ksu.edu/~rvprasad

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Fwd: ACCEPT/DROP]
  2002-12-20 13:54 [Fwd: ACCEPT/DROP] Venkatesh Prasad Ranganath
@ 2002-12-21 14:12 ` Markus Schaber
  2002-12-24 16:04   ` Patrick McHardy
  0 siblings, 1 reply; 6+ messages in thread
From: Markus Schaber @ 2002-12-21 14:12 UTC (permalink / raw)
  To: netfilter-devel

Hallo,

Venkatesh Prasad Ranganath <vranganath@cox.net> schrieb:

> I was looking into the iptables implementation and was intrigued about
> how iptables would handle a situation in which we have identical rules
> except for their targets which are contradicting, say ACCEPT and DROP.

This is a problem that _must_ be solved by the human being, because
equality of rules (as for other computer code) _cannot_ be computed.

(Equality of code is a broad area in computer science, e. G. a compiler
maker should be able to prove that the code after the optimization is
equal to the code before. It there is no general algorithm to prove the
equality of code, and it is proven that such an algorithm cannot exist,
except for very special cases. If you're interested in this subject, I
can give you some sources.)
 
>  By looking at ipt_do_table() function it seems that the first 
> non-IPT_RETURN  verdict from any standard target will end the
> traversal of a chain of a table, which seems to be a bit odd.  First,
> such conflicting rules must not be allowed.  Even beyond, this fails
> in the situation where you have a dropping rule added after an
> accepting rule.

Yes, and that's how iptables works. The creator of rules has to put the
rules into the correct order (that's why one can insert and remove rules
at arbitrary points).

> For example, a packet from m.n.o.p to a.b.c.d would be accepted at 
> a.b.c.d because of the first rule, although it had to be dropped 
> according to the second rule.   And this would result because of the 
> order in which the rules are added to the table.
> 
> iptables -A INPUT -d a.b.c.d -j ACCEPT
> iptables -A INPUT -s m.n.o.p -j DROP
> 
> Is my understanding correct?

Yes.

This is because your rules above say that traffic to a.b.c.d has to be
accepted from everywhere, and for all other possible destinations, drop
traffic from m.n.o.p.

This makes sense e. G. in case m.n.o.p is a portscanner, and you want to
block him except for your mail server a.b.c.d, so that he can answer on
your mailed complaint.

If you want to drop traffic for m.n.o.p even to a.b.c.d, you simply
change the order of the above rules.

>  If so, I am curious to know how nf-hipac behaves in such situations?

I didn't look into nf-hipac this far, but I don't think they can be much
different in this way.

Gruß,
Markus

-- 
Markus Schaber - http://www.schabi.de/

Schabi's Flohmarkt unter http://schabi.de/flohmarkt

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Fwd: ACCEPT/DROP]
  2002-12-21 14:12 ` Markus Schaber
@ 2002-12-24 16:04   ` Patrick McHardy
  2002-12-24 16:57     ` Miguel Amador L.
  2002-12-25 11:48     ` Thomas Heinz
  0 siblings, 2 replies; 6+ messages in thread
From: Patrick McHardy @ 2002-12-24 16:04 UTC (permalink / raw)
  To: Markus Schaber; +Cc: netfilter-devel

Hi,

On Sat, 21 Dec 2002, Markus Schaber wrote:

> Hallo,
> 
> Venkatesh Prasad Ranganath <vranganath@cox.net> schrieb:
> 
> > I was looking into the iptables implementation and was intrigued about
> > how iptables would handle a situation in which we have identical rules
> > except for their targets which are contradicting, say ACCEPT and DROP.
> 
> This is a problem that _must_ be solved by the human being, because
> equality of rules (as for other computer code) _cannot_ be computed.

This may be true for code, but iptables rules describe sets of packets
and you can detect identical rules (or rules which describe 
subsets/supersets) if you have knowledge what a particular match matches.
 
> (Equality of code is a broad area in computer science, e. G. a compiler
> maker should be able to prove that the code after the optimization is
> equal to the code before. It there is no general algorithm to prove the
> equality of code, and it is proven that such an algorithm cannot exist,
> except for very special cases. If you're interested in this subject, I
> can give you some sources.)

I am interested, please point me where to read more about this ..

Bye,
Patrick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Fwd: ACCEPT/DROP]
  2002-12-24 16:04   ` Patrick McHardy
@ 2002-12-24 16:57     ` Miguel Amador L.
  2002-12-25 11:48     ` Thomas Heinz
  1 sibling, 0 replies; 6+ messages in thread
From: Miguel Amador L. @ 2002-12-24 16:57 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Markus Schaber, netfilter-devel@lists.netfilter.org


Me too...
I am interested in the sources..

On Tue, 24 Dec 2002, Patrick McHardy wrote:

> Hi,
>
> On Sat, 21 Dec 2002, Markus Schaber wrote:
>
> > Hallo,
> >
> > Venkatesh Prasad Ranganath <vranganath@cox.net> schrieb:
> >
> > > I was looking into the iptables implementation and was intrigued about
> > > how iptables would handle a situation in which we have identical rules
> > > except for their targets which are contradicting, say ACCEPT and DROP.
> >
> > This is a problem that _must_ be solved by the human being, because
> > equality of rules (as for other computer code) _cannot_ be computed.
>
> This may be true for code, but iptables rules describe sets of packets
> and you can detect identical rules (or rules which describe
> subsets/supersets) if you have knowledge what a particular match matches.
>
> > (Equality of code is a broad area in computer science, e. G. a compiler
> > maker should be able to prove that the code after the optimization is
> > equal to the code before. It there is no general algorithm to prove the
> > equality of code, and it is proven that such an algorithm cannot exist,
> > except for very special cases. If you're interested in this subject, I
> > can give you some sources.)
>
> I am interested, please point me where to read more about this ..
>
> Bye,
> Patrick
>
>
>


 Miguel Angel Amador Lorca    |    mailto:amador@puc.cl
 "No sabiamos que era imposible,  por eso lo hicimos ... "

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Fwd: ACCEPT/DROP]
  2002-12-24 16:04   ` Patrick McHardy
  2002-12-24 16:57     ` Miguel Amador L.
@ 2002-12-25 11:48     ` Thomas Heinz
  2003-01-01 23:10       ` Markus Schaber
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Heinz @ 2002-12-25 11:48 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel

Hi Patrick

You wrote:
> This may be true for code, but iptables rules describe sets of packets

This is true for the basic cases only. In general the matches of a rule
must be considered to be arbitrary packet action (ACCEPT, DROP,
CONTINUE) returning functions that may even return different actions for
the same packet. The only constraint for matches is that they should
work read-only on the packet content, i.e. not modify it.

Of course your statement is correct in the context of the classical
packet classification problem.


Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Fwd: ACCEPT/DROP]
  2002-12-25 11:48     ` Thomas Heinz
@ 2003-01-01 23:10       ` Markus Schaber
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Schaber @ 2003-01-01 23:10 UTC (permalink / raw)
  To: netfilter-devel

Hi,

Thomas Heinz wrote:

> You wrote:
> > This may be true for code, but iptables rules describe sets of
> > packets
> 
> This is true for the basic cases only. In general the matches of a
> rule must be considered to be arbitrary packet action (ACCEPT, DROP,
> CONTINUE) returning functions that may even return different actions
> for the same packet. The only constraint for matches is that they
> should work read-only on the packet content, i.e. not modify it.

That's true, as examples one may see the state matches, or the random
match.


Markus

-- 
Schabi's Flohmarkt: http://www.uni-ulm.de/~s_mschab/flohmarkt/

Der Dienstweg ist die Verbindung der Sackgasse mit dem Holzweg!
[DoLi in unibwm.studium]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-01-01 23:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-20 13:54 [Fwd: ACCEPT/DROP] Venkatesh Prasad Ranganath
2002-12-21 14:12 ` Markus Schaber
2002-12-24 16:04   ` Patrick McHardy
2002-12-24 16:57     ` Miguel Amador L.
2002-12-25 11:48     ` Thomas Heinz
2003-01-01 23:10       ` Markus Schaber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.