1. Apr 20, 2016
    • Marco Angaroni's avatar
      ipvs: don't alter conntrack in OPS mode · 8fb04d9f
      Marco Angaroni authored
      
      
      When using OPS mode in conjunction with SIP persistent-engine, packets
      originating from the same ip-address/port could be balanced to different
      real servers, and (to properly handle SIP responses) OPS connections
      are created in the in-out direction too, where ip_vs_update_conntrack()
      is called to modify the reply tuple.
      
      As a result, there can be collision of conntrack tuples, causing random
      packet drops, as explained below:
      
      conntrack1: orig=CIP->VIP, reply=RIP1->CIP
      conntrack2: orig=RIP2->CIP, reply=CIP->VIP
      
      Tuple CIP->VIP is both in orig of conntrack1 and reply of conntrack2.
      The collision triggers packet drop inside nf_conntrack processing.
      
      In addition, the current implementation deletes the conntrack object at
      every expire of an OPS connection (once every forwarded packet), to have
      it recreated from scratch at next packet traversing IPVS.
      
      Since in OPS mode, by definition, we don't expect any associated
      response, the choices implemented in this patch are:
      a) don't call nf_conntrack_alter_reply() for OPS connections inside
         ip_vs_update_conntrack().
      b) don't delete the conntrack object at OPS connection expire.
      
      The result is that created conntrack objects for each tuple CIP->VIP,
      RIP-N->CIP, etc. are left in UNREPLIED state and not modified by IPVS
      OPS connection management. This eliminates packet drops and leaves
      a single conntrack object for each tuple packets are sent from.
      
      Signed-off-by: default avatarMarco Angaroni <marcoangaroni@gmail.com>
      Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      8fb04d9f
    • Marco Angaroni's avatar
      ipvs: optimize release of connections in OPS mode · 013b0424
      Marco Angaroni authored
      
      
      One-packet-scheduling is the most expensive mode in IPVS from
      performance point of view: for each packet to be processed a new
      connection data structure is created and, after packet is sent,
      deleted by starting a new timer set to expire immediately.
      
      SIP persistent-engine needs OPS mode to have Call-ID based load
      balancing, so OPS mode performance has negative impact in SIP
      protocol load balancing.
      
      This patch aims to improve performance of OPS mode by means of the
      following changes in the release mechanism of OPS connections:
      a) call expire callback ip_vs_conn_expire() directly instead of
         starting a timer programmed to fire immediately.
      b) avoid call_rcu() overhead inside expire callback, since OPS
         connection are not inserted in the hash-table and last just the
         time to process the packet, hence there is no concurrent access
         to such data structures.
      
      Signed-off-by: default avatarMarco Angaroni <marcoangaroni@gmail.com>
      Acked-by: default avatarJulian Anastasov <ja@ssi.bg>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      013b0424
    • Marco Angaroni's avatar
      ipvs: handle connections started by real-servers · 39b97223
      Marco Angaroni authored
      
      
      When using LVS-NAT and SIP persistence-egine over UDP, the following
      limitations are present with current implementation:
      
        1) To actually have load-balancing based on Call-ID header, you need to
           use one-packet-scheduling mode. But with one-packet-scheduling the
           connection is deleted just after packet is forwarded, so SIP responses
           coming from real-servers do not match any connection and SNAT is
           not applied.
      
        2) If you do not use "-o" option, IPVS behaves as normal UDP load
           balancer, so different SIP calls (each one identified by a different
           Call-ID) coming from the same ip-address/port go to the same
           real-server. So basically you don’t have load-balancing based on
           Call-ID as intended.
      
        3) Call-ID is not learned when a new SIP call is started by a real-server
           (inside-to-outside direction), but only in the outside-to-inside
           direction. This would be a general problem for all SIP servers acting
           as Back2BackUserAgent.
      
      This patch aims to solve problems 1) and 3) while keeping OPS mode
      mandatory for SIP-UDP, so that 2) is not a problem anymore.
      
      The basic mechanism implemented is to make packets, that do not match any
      existent connection but come from real-servers, create new connections
      instead of let them pass without any effect.
      When such packets pass through ip_vs_out(), if their source ip address and
      source port match a configured real-server, a new connection is
      automatically created in the same way as it would have happened if the
      packet had come from outside-to-inside direction. A new connection template
      is created too if the virtual-service is persistent and there is no
      matching connection template found. The new connection automatically
      created, if the service had "-o" option, is an OPS connection that lasts
      only the time to forward the packet, just like it happens on the
      ingress side.
      
      The main part of this mechanism is implemented inside a persistent-engine
      specific callback (at the moment only SIP persistent engine exists) and
      is triggered only for UDP packets, since connection oriented protocols, by
      using different set of ports (typically ephemeral ports) to open new
      outgoing connections, should not need this feature.
      
      The following requisites are needed for automatic connection creation; if
      any is missing the packet simply goes the same way as before.
      a) virtual-service is not fwmark based (this is because fwmark services
         do not store address and port of the virtual-service, required to
         build the connection data).
      b) virtual-service and real-servers must not have been configured with
         omitted port (this is again to have all data to create the connection).
      
      Signed-off-by: default avatarMarco Angaroni <marcoangaroni@gmail.com>
      Acked-by: default avatarJulian Anastasov <ja@ssi.bg>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      39b97223
  2. Apr 19, 2016
  3. Apr 14, 2016
  4. Apr 13, 2016
  5. Apr 12, 2016