I believe I constructed an irule to properly a variable from text captured from two distinct points in the TCP Payload but I am not 100% certain the Irule will is persisting off this entity. can someone take a look below and see if this looks correct? I added the message load balancing profile on as well.
The expectations are tat after collecting tcp payload for a new connection search for a string and then persists that string to a certain pool ( contains 2 servers). all subsequent matches for that same string in payload need to go to that pool. I also want the pool to load balance diverse entities so not everything is on the same pool member. Does this look correct ?
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
set payload [TCP::payload]
set entityID [findstr $payload "@" 1 ","]
log local0. "$entityID: $entityID"
pool XYZ
persist uie $entityID
log local4.info " Entity Session routing $entityID and setting persistence"
TCP::release
TCP::notify request
}
It looks like the iRule should work as it is. Are you seeing different or just questioning if it could fail?
Unless you’re specifically doing mblb, I don’t think you need the TCP::notify. TCP load balancing is by default session-based, so all traffic within a single TCP session will stick to the same node after an initial decision. I threw in some additional logging to show what the persistence record actually points to per TCP session.
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
set entityID [findstr [TCP::payload] "User-Agent: " 12 " "]
log local0. "entityID = $entityID"
persist uie $entityID
log local0. "using persistence for entityId ($entityID): [persist lookup uie $entityID]"
TCP::release
}
I think what Giltjr is asking is if the entityID value will be in every TCP packet? Load balancing persistence is (TCP) session-based. Beyond that you need some pervasive mechanism to maintain that persistence across multiple TCP sessions. The client must pass some unique and persistent value in every new TCP session for this to work.
the entity ID will only be available in the first few TCP packets then it will no longer appear.
That could potentially be a problem. You’ll need some piece of information from the client in each new TCP session after the initial load balancing decision to maintain that persistence. Is this a protocol that maintains one long TCP session, or is it like HTTP and can have multiple TCP sessions over the life of the application session?
If the latter, is there anything else unique about the client that can be used, or is supported by the client for persistence? Is source address an option?
First, just add a log local0. [TCP::payload] statement in your CLIENT_DATA event. I’m also guessing from this output that the collected data isn’t text, and more important, there’s more than one TCP session. Before going any further, add that additional log statement and see what the payload actually looks like.
I added the log statement as recommended and also added MBLB profile as well. still the output from the ltm logs shows garbled. I am including the TCP payload from the packet capture as this data s text based and there is no reason the ltm should show garbled text. Here is the first push-ack from the GUI to the LTM after the 3 way handshake. the string I need to load balance is right there.
just to be safe i tried viewing the log output from a different ssh client. both ssh tectia and Putty show slightly different formats of the payload. I am wondering if the LTM is simply not formatting the output correctly but is actually parsing correctly ?
SSH Tectia Client:
Jul 7 18:08:43 info tmm1[13133]: Rule /Common/Entity_Irule : o:t=)¾Ã¯c^¬ö|¤£ Jul 7 18:08:43 1 info tmm1[13133]: Rule /Common/Entity_Irule : À¾ÀÀºS»kWgâ ¬Â[ûÀÀ8à ÃÀ5ÃÃÀ9À8à ÃÀ/ÃÃÀ3À2ÃÃÀÃà ÃÀ Ãà ÀÀÀÀÿÀÀYÀ À4À2ÀÀÀÀÀÀÀÀ À ÀÀ À ÀÀ ÀÀÀÀÀÀÀÀÀÀÀ ÀÀÀÀÀÀÀÀqems.qa2.fxall.com Jul 7 18:08:48 1 info tmm5[13134]: Rule /Common/Entity_Irule : ÀÃÀÀÃS»pÃYÃJÃà ëþ·Â·Dü,K\¥µXmÂN «lì?oøáÃ}Iì)ELÃBõo à 1ÂYC$¿ÃÀ8à ÃÀ5ÃÃÀ9À8à ÃÀ/ÃÃÀ3À2ÃÃÀÃà ÃÀ Ãà ÀÀÀÀÿÀÀYÀ À4À2ÀÀÀÀÀÀÀÀ À ÀÀ À ÀÀ ÀÀÀÀÀÀÀÀÀÀÀ ÀÀÀÀÀÀÀÀqems.qa2.fxall.com Jul 7 18:08:48 info tmm5[13134]: Rule /Common/Entity_Irule : Jul 7 18:08:48 debug tmm5[13134]: Rule /Common/Entity_Irule : Entity Session routing and setting persistence ^[[?1;2cVT102VT102VT102^[[?1;2cVT102VT102VT102
Ahhhh. I may have missed this earlier, but I see you’re using a client SSL profile, which explains why the TCP data is garbled. TCP is OSI layer 4, but SSL offload doesn’t happen until layer 6. You can generally replace the TCP:: commands with SSL:: commands and accomplish the same thing (but after decryption). Take a look at the SSL::collect wiki page for an example.
I made some good progess with the SSL irule and now the entity is correctly parsed out, but i think im missing something still as the connection never truly completes.
Here is the current irule:
when CLIENTSSL_HANDSHAKE {
log local0. "[IP::client_addr]:[TCP::client_port]: SSL handshake completed, collecting SSL payload"
SSL::collect
}
when CLIENTSSL_DATA {
set payload [SSL::payload]
set entityID [findstr $payload "@" 1 ","]
log local0. "$entityID: $entityID"
pool xxx_yyyy_Pool
log local0. "blha Entity Session routing $entityID and setting persistence"
persist uie $entityID 64000
SSL::release
}
Here are the log output when logging in: (at times I commented out the persist line since it throws tcl errors below)
Jul 8 17:57:56 va-bigip01 info tmm2[13133]: Rule /Common/x_Entity_Irule : 10.65.59.202:56070: SSL handshake completed, collecting SSL payload Jul 8 17:57:56 va-bigip01 info tmm2[13133]: Rule /Common/x_Entity_Irule : QA-xxx-CUST1: QA-xxx-CUST1 Jul 8 17:57:56 va-bigip01 info tmm2[13133]: Rule /Common/x_Entity_Irule : x Entity Session routing QA-xxx-CUST1 and setting persistence Jul 8 17:58:01 va-bigip01 info tmm7[13134]: Rule /Common/x_Entity_Irule : 10.65.59.202:56074: SSL handshake completed, collecting SSL payload Jul 8 17:58:01 va-bigip01 info tmm7[13134]: Rule /Common/x_Entity_Irule : : Jul 8 17:58:01 va-bigip01 info tmm7[13134]: Rule /Common/xEntity_Irule : x Entity Session routing and setting persistence Jul 8 18:04:22 va-bigip01 info tmm5[13134]: Rule /Common/x_Entity_Irule : 10.65.59.202:53658: SSL handshake completed, collecting SSL payload Jul 8 18:04:22 va-bigip01 info tmm5[13134]: Rule /Common/x_Entity_Irule : QA-xxx-PROV1: QA-xxx-PROV1 Jul 8 18:04:22 va-bigip01 info tmm5[13134]: Rule /Common/x_Entity_Irule : x Entity Session routing QA-xxx-PROV1 and setting persistence Jul 8 18:04:26 va-bigip01 info tmm4[13134]: Rule /Common/x_Entity_Irule : 10.65.59.202:53668: SSL handshake completed, collecting SSL payload Jul 8 18:04:26 va-bigip01 info tmm4[13134]: Rule /Common/x_Entity_Irule : : Jul 8 18:04:26 va-bigip01 info tmm4[13134]: Rule /Common/x_Entity_Irule : x Entity Session routing and setting persistence Jul 8 18:04:26 va-bigip01 err tmm4[13134]: 01220001:3: TCL error: /Common/x_Entity_Irule - attempt to use empty persistence key (line 1) invoked from within “persist uie $entityID 64000”
I also noticed the unviersal persistence when set doesn’t seem to send the next entity to the next pool member even though the connection is not completing. in the output below I expect that all future uses matching CUST2 stay on 10.36.35:9820 but entity PROV1 be put on the other pool member 10.36.6.35:9820 not shown here
Okay, so given the log data (cleaned up for viewing):
10.65.59.202:56070: SSL handshake completed, collecting SSL payload
QA-xxx-CUST1: QA-xxx-CUST1
x Entity Session routing QA-xxx-CUST1 and setting persistence
10.65.59.202:56074: SSL handshake completed, collecting SSL payload
:
x Entity Session routing and setting persistence
10.65.59.202:53658: SSL handshake completed, collecting SSL payload
QA-xxx-PROV1: QA-xxx-PROV1
x Entity Session routing QA-xxx-PROV1 and setting persistence
10.65.59.202:53668: SSL handshake completed, collecting SSL payload
:
x Entity Session routing and setting persistence
TCL error: /Common/x_Entity_Irule - attempt to use empty persistence key (line 1) invoked from within "persist uie $entityID 64000"
Two things are evident:
Every other TCP session is missing the entityID data in the payload. The source port is different each time, so is this a single client interaction, or are you testing repeatedly?
You should probably check that the $entityID variable has something in it before attempting to use it for persistence
It may be more helpful at this point to spin up Wireshark to observe these interactions through a native connection (without LTM SSL offload). You can configure it to decrypt the SSL payload by inserting the private key into the RSA list of the SSL configuration. At a minimum you want to verify that the entityID is indeed in every request packet.
after initial 3 way handshake the GUI does send the entity ID as indicated by the logging result. subsequent packets from the GU are small 64 byte len and contain no readable payload until a few seconds later where the GUI send HB events that contain the entity ID. during this time the F5 is sending to the GUI all different data related to the application.
i guess what I am looking for is a way to persist the connection once the entityID is parsed and identified and stop collecting right after that point?
the entityID does have the string I need in it. right after we set the variable and log it i have a LB decision to be made but never see it complete, so i think its keeps collecting further and thats why it shows up emtpy the next time around.