Skip to contentSkip to conversation

Adapting LVS in order to allow Call-Id based persistence

DISCUSSION Joseph Mack NA3T 3 participants 8 messages Apr 2, 2008 – Apr 4, 2008 2 messages not in the archive IPVS

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 1 line · pierrick grasland

So, in order to simplify my setup, I was hoping to implement something which will allow ipvsadm to track call-id, and not <ip:port> connections.

I notice that you've sent this e-mail to me personally. I hope you don't mind if I cc this reply to the lvs-devel list, as the people there will have ideas about this.

you're going where few people have gone. The various L7 packages you mention associated with LVS are not in common use. I assume this is because they're difficult to set up (they're general) and noone needs them enough to bother.

However SIP keeps coming up on this list and lvs can't handle SIP out of the box, so something will have to be done about it.

Quoted 1 line

I have browse some sources (ktcpvs, ipvsadm, l7vsadm, l7directord), but I'm actually lost. All these packages allow some application level routing for HTTP, but are based at differents levels (kernel for ktcpvs, user for ipvsadm/l7vsadm, l7directord seems to be an addon for configuration of l7vsadm and health check for realserver).

It's not obvious to me which, if any are suitable starting points, but you should know the code to get ideas.

I expect the best idea would be a sip helper, like the ftp helper module. It will have to know all about SIP and unlike the other L7 packages, would need little if any configuring. Presumably you could start with a module that recognises the UDP packets you've been using for tests. The ftp helper just looks at the tcpip headers. You'll have to look inside the packet. There's a u32 option to iptables that looks inside packets - you should find out how that works.

You're going to have to write a scheduler based on call-id as well. I like the -SH scheduler for for getting persistence based on CIP, rather than the standard LVS persistence code, which hangs if the client disappears. I don't know if the call-id can be associated with an IP.

Horms has talked about a SIP helper (I think - at least he's talked about SIP). He may have even have some code.

Horms:

Other people have come and gone asking about SIP, but Pierrick seems to be taking more than a casual interest in getting SIP running under LVS. He has got the UDP connect packet to work under LVS, which is further than anyone else has gone. Got any ideas on how he should proceed?

Joe

Quoted 6 lines

I hope you will be able to indicate which package can be a good starting point, and some hints which can be useful.

Thanks for your help,

Signature · 4 lines
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
maintainer
#2 lore raw

Hi Pierrick, Hi Joe,

I'm a bit rusty on SIP as it is several years since I worked on it, but I have found a local version of my patches and had a look over them.

Basically my idea was to establish "persistence engines" inside LVS. That is, to allow LVS to have modules that determine persistence - kind of analogous to the scheduling modules that are already present in LVS. This would in theory allow different persistence models to be combined with each of the existing scheduling modules.

[new connection rx] -> [persistence engine] -> [scheduler] -> [xmit]

I then implemented a SIP persistence module that did persistence using the Caller-Id as the key rather than the usual ip:port key.

I can't actually remember how well it worked, all I can find in my notes is a reference to the project being halted before it was finished. (I do recall having a lot of trouble getting SIP to work at all due to unreliable SIP software stacks, but as I mentioned, it was a while ago.)

I should note that the patches I have are against a rather ancient kernel - 2.4.26. But if there is interest in them I can talk to the client for that project about releasing the code.

Signature · 1 line
Horms

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 4 lines · pierrick grasland

But how do you work with persistence ? (actually, with -p options).

Each call during the interval go to the same server, and then, do you reset the timer for each new call) or no ?

I'd defer to Horms on this if he thinks otherwise but... I wouldn't do it that way. There's all sorts of problems with using a timer in the lvs (-p) persistence to detect a returning client and I'm trying to convince people to move to the -SH scheduler instead.

The -SH scheduler addresses the same problem, but by scheduling on the CIP. As long as the client doesn't change IPs within their session, then you're OK (this is valid except for people using pathologically configured proxy setups).

I don't know if you can us the CIP to uniquely identify a client in SIP. If not, you'll have to do it on call-id.

Joe

Signature · 4 lines
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
#5 lore raw

1) IMHO, we don't have to allow persistence for more than a call .

I'm hoping to detect a call Id, set a timer for this call Id, corresponding to persistence. But a phone call as a very variable time, from short call (less than 30s) to long call (more than 15 minutes, and my stats are only based on my bills ^^).

We can't allow a connexion logged as active for days, but if I'm in the following case (basic call flow in SIP) :

Bob = INVITE => proxy1 = INVITE =>LVS = INVITE => realserver (proxy2) = INVITE ===> Alice
Bob <= 200 OK = proxy1 <= 200 ok = LVS <= 200 ok = realserver (proxy2)<= 200 ok === Alice
Bob = ACK => proxy1 = ACK =>LVS = ACK => realserver (proxy2) = ACK =========> Alice

Bob <==========================RTP===============================> Alice

Bob <= BYE = proxy1 <= BYE = LVS <= BYE = realserver <= BYE =============== Alice
Bob = 200 OK => proxy1 = 200 OK =>LVS = 200 OK => realserver (proxy2) = 200 OK => Alice

Then, we don't have SIP messages exchanged during the length of the communication, which use RTP. But, we must transfer the BYE in order to close the call.

I think we have several options here :
- hash (seems practical, but I don't know how it's react in case of addition / deletion of server)
- timers
- parsing sip headers in order to detect call terminaison, which seems totally impractical with a DR setup (we don't see all messages exchange from the 2 clients)

So, just for an example, I wish to know how do you implement persistence for HTTP.

2) I'm actually browsing sources from kernel 2.6.24 (just for a better idea on the architecture). I found IPVS in linux-2.6.24.4/net/ipv4/ipvs.
Does all sources are located in this folder ? Nothing with netfilter ?

PS : I have time to make something valuable (ie 4 months). I'm in internship, and this is my subject.

Signature · 4 lines
Grasland Pierrick
NEXCOM Systems
LANNION
FRANCE
#6 lore raw
Quoted 6 lines · pierrick grasland

1) IMHO, we don't have to allow persistence for more than a call .

I'm hoping to detect a call Id, set a timer for this call Id, corresponding to persistence. But a phone call as a very variable time, from short call (less than 30s) to long call (more than 15 minutes, and my stats are only based on my bills ^^).

does the call id get refreshed during the call, ie is it sent with every packet, ie can you update the timer? If not and it's only sent on the invite and bye, then you don't know if the call has gone away without a bye and you'll need a long timeout.

Quoted 3 lines

Then, we don't have SIP messages exchanged during the length of the communication, which use RTP. But, we must transfer the BYE in order to close the call.

what if you loose the BYE packet?

Quoted 7 lines

I think we have several options here :
- hash (seems practical, but I don't know how it's react in case of addition / deletion of server)
- timers
- parsing sip headers in order to detect call terminaison, which seems totally impractical with a DR setup (we don't see all messages exchange from the 2 clients)

LVS-DR is doable as the IP layer has fixed timeouts. If the information you need to terminate a call isn't available in LVS-DR, then maybe SIP will be limited to LVS-NAT. Alternately you could start with LVS-NAT and leave LVS-DR to be figured out later.

Joe

Signature · 4 lines
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
maintainer
#7 lore raw
In reply to pierrick grasland
Quoted 29 lines · pierrick grasland

1) IMHO, we don't have to allow persistence for more than a call .

I'm hoping to detect a call Id, set a timer for this call Id, corresponding to persistence. But a phone call as a very variable time, from short call (less than 30s) to long call (more than 15 minutes, and my stats are only based on my bills ^^).

We can't allow a connexion logged as active for days, but if I'm in the following case (basic call flow in SIP) :

Bob = INVITE => proxy1 = INVITE =>LVS = INVITE => realserver (proxy2) = INVITE ===> Alice
Bob <= 200 OK = proxy1 <= 200 ok = LVS <= 200 ok = realserver (proxy2)<= 200 ok === Alice
Bob = ACK => proxy1 = ACK =>LVS = ACK => realserver (proxy2) = ACK =========> Alice

Bob <==========================RTP===============================> Alice

Bob <= BYE = proxy1 <= BYE = LVS <= BYE = realserver <= BYE =============== Alice
Bob = 200 OK => proxy1 = 200 OK =>LVS = 200 OK => realserver (proxy2) = 200 OK => Alice

Then, we don't have SIP messages exchanged during the length of the communication, which use RTP. But, we must transfer the BYE in order to close the call.

Quoted 7 lines

I think we have several options here :
- hash (seems practical, but I don't know how it's react in case of addition / deletion of server)
- timers
- parsing sip headers in order to detect call terminaison, which seems totally impractical with a DR setup (we don't see all messages exchange from the 2 clients)

Yes, this all sounds very familiar.

The parsing approach sounds like a good idea, are you sure that the packet-flow makes it impractical when DR is used? It seems such a shame not to be able to use such a good idea.

The timeout idea is the most obvious approach, and probably the best. But really long timeouts might well be needed. I mean, its not uncommon for a phone call to go for several hours.

As for the hash, yes, I share your concern there.

Quoted 7 lines

So, just for an example, I wish to know how do you implement persistence for HTTP.

2) I'm actually browsing sources from kernel 2.6.24 (just for a better idea on the architecture). I found IPVS in linux-2.6.24.4/net/ipv4/ipvs.
Does all sources are located in this folder ? Nothing with netfilter ?

There is also a header file, include/net/ip_vs.h

IPVS does use some of the netfilter code, but you probably only need to study what is in net/ipv4/ipvs and include/net/ip_vs.h to understand what is going on.

Quoted 7 lines

PS : I have time to make something valuable (ie 4 months). I'm in internship, and this is my subject.

Signature · 4 lines
Grasland Pierrick
NEXCOM Systems
LANNION
FRANCE
Signature · 1 line
Horms
maintainer
#8 lore raw
In reply to Joseph Mack NA3T
Quoted 12 lines · On Thu, Apr 03, 2008 at 06:25:20AM -0700, Joseph Mack NA3T wrote:
Quoted 4 lines · pierrick grasland

But how do you work with persistence ? (actually, with -p options).

Each call during the interval go to the same server, and then, do you reset the timer for each new call) or no ?

I'd defer to Horms on this if he thinks otherwise but... I wouldn't do it that way. There's all sorts of problems with using a timer in the lvs (-p) persistence to detect a returning client and I'm trying to convince people to move to the -SH scheduler instead.

Quoted 7 lines

The -SH scheduler addresses the same problem, but by scheduling on the CIP. As long as the client doesn't change IPs within their session, then you're OK (this is valid except for people using pathologically configured proxy setups).

I don't know if you can us the CIP to uniquely identify a client in SIP. If not, you'll have to do it on call-id.

I think that in the case that I was looking at this would not have worked well as all the traffic came from the same IP address or a handful of IP addresses - think in terms of handling requests from a proxy server.

However, -SH might be a good approach for many cases.

Signature · 1 line
Horms
maintainer
#9 lore raw
In reply to a message not in the archive
Quoted 5 lines · pierrick grasland

Hi,

What I have in mind is the same kind of architecture (I think it's because I have read the HOWTO's chapter on SIP before).
So, even if it's for an older kernel, it will be interesting to see it.

I will speak with my client about posing the patches - though it may take a while as big companies sometimes move quite slowly.

Quoted 3 lines

Also, I have some questions about general organization of ipvs/ipvsadm. If I understand this correctly, it's ipvs which receive inbound connection and schedule them following the different services created with ipvsadm.

ipvsadm runs in user-space and is used to configure ipvs. ipvs lives inside the kernel and does all the real work.

Quoted 4 lines

But how do you work with persistence ? (actually, with -p options).

Each call during the interval go to the same server, and then, do you reset the timer for each new call) or no ?

Ok, this is something that I have tired to explain several times without success. I'll have another go.

When a packet comes in the hash of known connections is checked. If an entry there is found then it is used and the information in this entry tells ipvs which real-server to forward the connection to. The entry has a timeout which is updated each time a packet for it is forwarded.

If an entry is not found, then a new one is created and a real-server is assigned using the scheduling algorithm (as configured by ipvsadm).

For persistent services, a template is also kept which models persistance. Before going to the scheduler for a new connection the template is looked up. If it is found then its real-server is used for the connection. If not, the scheduler is used to create both a new entry for the new connection and a new template.

These templates also have a timeout (as configured by ipvsadm), which is reset each time a packet is forwarded for any connections whose entry used the template in question.

For persistent connections you can think of the template as a parent of all the connections from the same host (masked with the netmask configured by ipvsadm).

For non-persistent connections, there is no parent-child relationship as there are no templates.

Signature · 1 line
Horms