Skip to contentSkip to conversation

ebtables extension 'http'

DISCUSSION Felipe W Damasio 5 participants 10 messages Jan 25, 2010 – Jan 26, 2010 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

I'm using squid to cache all the content from certain domains, such
as amazon.com, googlevideo.com, etc.

But when using:

ebtables -t broute -A BROUTING -p ipv4 --ip-proto tcp --ip-dport 80 -j redirect --redirect-target DROP

All the http traffic is routed...and my squid doesn't handle it
well, since the ISP in question has a 600Mbps with about 10-12,000 users.

So I thought I could develop something like this:

ebtables -t broute -A BROUTING -p ipv4 --ip-proto tcp --ip-dport 80 --http-domain '.*googlevideo.com.*' -j redirect --redirect-target DROP

And match the regexp --http-domain with the http header on (each)
packet the match "--ip-dport 80".

This way all the non-cacheable traffic doesn't get routed, it's
forwarded along all other traffic, and only the desirable packets are routed to iptables and then squid.

What do you guys think? Could this be done?

Any thoughts would be appreciated.

Cheers,

Felipe Damasio

#1 lore raw
Quoted 6 lines · Felipe W Damasio

This way all the non-cacheable traffic doesn't get routed, it's
forwarded along all other traffic, and only the desirable packets are routed to iptables and then squid.

What do you guys think? Could this be done?

For the same reason:
http://l7-filter.sourceforge.net/FAQ#usage

#2 lore raw

Hi Mr. Jan,

2010/1/25 Jan Engelhardt <[email protected]>:

Quoted 2 lines

For the same reason:
http://l7-filter.sourceforge.net/FAQ#usage

Right, thanks!

But I just don't see the point of letting all the http traffic flows
through squid since it'll only care about a handful of domains...

I don't suppose there is a way of "putting" the connection back on
the forwarding-state on the bridge after ebtables already dropped it on the broute table, is there?

I was trying to get something like "if the domain is not
www.amazon.com, but it back on the bridge"...

Thanks!

Felipe Damasio

#3 lore raw
Quoted 11 lines · Felipe W Damasio
Quoted 2 lines

For the same reason:
http://l7-filter.sourceforge.net/FAQ#usage

Right, thanks!

But I just don't see the point of letting all the http traffic flows
through squid since it'll only care about a handful of domains...

I don't suppose there is a way of "putting" the connection back on
the forwarding-state on the bridge after ebtables already dropped it on the broute table, is there?

Once you decided which machine handles the packet stream, it's decided. The twist is, you have to decide when you see the very first packet.

#4 lore raw
Quoted 8 lines · Jan Engelhardt
Quoted 7 lines · Felipe W Damasio
Quoted 2 lines

For the same reason:
http://l7-filter.sourceforge.net/FAQ#usage

Right, thanks!

But I just don't see the point of letting all the http traffic flows
through squid since it'll only care about a handful of domains...

Quoted 6 lines
Quoted 3 lines

I don't suppose there is a way of "putting" the connection back on
the forwarding-state on the bridge after ebtables already dropped it on the broute table, is there?

Once you decided which machine handles the packet stream, it's decided. The twist is, you have to decide when you see the very first packet.

CT actually doesn't really care, it should be possible with TPROXY if the local socket could be persuaded to close silently.

#5 lore raw
Quoted 10 lines · Patrick McHardy
Quoted 10 lines
Quoted 9 lines
Quoted 1 line

http://l7-filter.sourceforge.net/FAQ#usage

Right, thanks!

But I just don't see the point of letting all the http traffic flows
through squid since it'll only care about a handful of domains...

I don't suppose there is a way of "putting" the connection back on
the forwarding-state on the bridge after ebtables already dropped it on the broute table, is there?

Quoted 5 lines
Quoted 2 lines

Once you decided which machine handles the packet stream, it's decided. The twist is, you have to decide when you see the very first packet.

CT actually doesn't really care, it should be possible with TPROXY if the local socket could be persuaded to close silently.

The issue is that you would need to replay the tcp handshake.

Case 1:
- do TCP handshake
- read out Host: header
- if proxied
- good
- if not,
- have to replay TCP handshake to next host (eww :-)

#6 lore raw
Quoted 17 lines · Jan Engelhardt
Quoted 6 lines · Patrick McHardy
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

http://l7-filter.sourceforge.net/FAQ#usage

Right, thanks!

But I just don't see the point of letting all the http traffic flows
through squid since it'll only care about a handful of domains...

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I don't suppose there is a way of "putting" the connection back on
the forwarding-state on the bridge after ebtables already dropped it on the broute table, is there?

Once you decided which machine handles the packet stream, it's decided. The twist is, you have to decide when you see the very first packet.

CT actually doesn't really care, it should be possible with TPROXY if the local socket could be persuaded to close silently.

The issue is that you would need to replay the tcp handshake.

Quoted 7 lines

Case 1:
- do TCP handshake
- read out Host: header
- if proxied
- good
- if not,
- have to replay TCP handshake to next host (eww :-)

You're right, that wouldn't work without even mory ugly.

#7 lore raw
In reply to Jan Engelhardt

Hi Mr. Jan

2010/1/25 Jan Engelhardt <[email protected]>:

Quoted 9 lines

The issue is that you would need to replay the tcp handshake.

Case 1:
- do TCP handshake
- read out Host: header
- if proxied
 - good
- if not,
 - have to replay TCP handshake to next host (eww :-)

Would this be so bad? :-)

I mean, if I could do this, I could reduce the HTTP traffic from
around 400Mbps to around 100Mbps of domains that the proxy actually do cares.

And the rest would be forwarded down the bridge.

Could I do this with repeating the TCP handshake with the next host?
How could I do this?

Thanks,

Felipe Damasio
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

Hello,

Quoted 12 lines · Felipe W Damasio

2010/1/25 Jan Engelhardt <[email protected]>:

Quoted 9 lines

The issue is that you would need to replay the tcp handshake.

Case 1:
- do TCP handshake
- read out Host: header
- if proxied
- good
- if not,
- have to replay TCP handshake to next host (eww :-)

Quoted 1 line

Would this be so bad? :-)

Yes, quite, because it must be transparent to the client. However the new server may have a lower MSS and not support some TCP options such as windows scaling, ECN, selective ACK, window scaling, timestamps... that the previous one supported and which are transmitted only during the handshake, so the client would not know about. Not to mention that of course it will use a different initial sequence number and it would have to be translated by the bridge in each packet.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
Quoted 15 lines · Pascal Hambourg

Hello,

Quoted 12 lines · Felipe W Damasio

2010/1/25 Jan Engelhardt <[email protected]>:

Quoted 9 lines

The issue is that you would need to replay the tcp handshake.

Case 1:
- do TCP handshake
- read out Host: header
- if proxied
 - good
- if not,
 - have to replay TCP handshake to next host (eww :-)

Quoted 7 lines
Quoted 1 line

  Would this be so bad? :-)

Yes, quite, because it must be transparent to the client. However the new server may have a lower MSS and not support some TCP options such as windows scaling, ECN, selective ACK, window scaling, timestamps... that the previous one supported and which are transmitted only during the handshake, so the client would not know about.

how about learning this info from the next hop by sending a SYN packet with all options set and the largest MSS. It sounds like TCP splicing and SYN proxy. And I heard some one had implemented SYN proxy in Linux, and xBSD also support SYN proxy. Is there any chance to integrate SYN proxy and TCP splicing into Linux?

Quoted 3 lines

Not to mention that of
course it will use a different initial sequence number and it would have to be translated by the bridge in each packet.

NAT also need to take care of this, so we can reuse the code already in the kernel maybe.

Signature · 6 lines
Regards,
Changli Gao([email protected])
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html