1. 02 2月, 2017 2 次提交
  2. 06 6月, 2016 1 次提交
    • M
      ipvs: update real-server binding of outgoing connections in SIP-pe · 3ec10d3a
      Marco Angaroni 提交于
      Previous patch that introduced handling of outgoing packets in SIP
      persistent-engine did not call ip_vs_check_template() in case packet was
      matching a connection template. Assumption was that real-server was
      healthy, since it was sending a packet just in that moment.
      
      There are however real-server fault conditions requiring that association
      between call-id and real-server (represented by connection template)
      gets updated. Here is an example of the sequence of events:
        1) RS1 is a back2back user agent that handled call-id1 and call-id2
        2) RS1 is down and was marked as unavailable
        3) new message from outside comes to IPVS with call-id1
        4) IPVS reschedules the message to RS2, which becomes new call handler
        5) RS2 forwards the message outside, translating call-id1 to call-id2
        6) inside pe->conn_out() IPVS matches call-id2 with existing template
        7) IPVS does not change association call-id2 <-> RS1
        8) new message comes from client with call-id2
        9) IPVS reschedules the message to a real-server potentially different
           from RS2, which is now the correct destination
      
      This patch introduces ip_vs_check_template() call in the handling of
      outgoing packets for SIP-pe. And also introduces a second optional
      argument for ip_vs_check_template() that allows to check if dest
      associated to a connection template is the same dest that was identified
      as the source of the packet. This is to change the real-server bound to a
      particular call-id independently from its availability status: the idea
      is that it's more reliable, for in->out direction (where internal
      network can be considered trusted), to always associate a call-id with
      the last real-server that used it in one of its messages. Think about
      above sequence of events where, just after step 5, RS1 returns instead
      to be available.
      
      Comparison of dests is done by simply comparing pointers to struct
      ip_vs_dest; there should be no cases where struct ip_vs_dest keeps its
      memory address, but represent a different real-server in terms of
      ip-address / port.
      
      Fixes: 39b97223 ("ipvs: handle connections started by real-servers")
      Signed-off-by: NMarco Angaroni <marcoangaroni@gmail.com>
      Acked-by: NJulian Anastasov <ja@ssi.bg>
      Signed-off-by: NSimon Horman <horms@verge.net.au>
      3ec10d3a
  3. 20 4月, 2016 1 次提交
    • M
      ipvs: handle connections started by real-servers · 39b97223
      Marco Angaroni 提交于
      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: NMarco Angaroni <marcoangaroni@gmail.com>
      Acked-by: NJulian Anastasov <ja@ssi.bg>
      Signed-off-by: NSimon Horman <horms@verge.net.au>
      39b97223
  4. 07 3月, 2016 1 次提交
    • J
      ipvs: drop first packet to redirect conntrack · f719e375
      Julian Anastasov 提交于
      Jiri Bohac is reporting for a problem where the attempt
      to reschedule existing connection to another real server
      needs proper redirect for the conntrack used by the IPVS
      connection. For example, when IPVS connection is created
      to NAT-ed real server we alter the reply direction of
      conntrack. If we later decide to select different real
      server we can not alter again the conntrack. And if we
      expire the old connection, the new connection is left
      without conntrack.
      
      So, the only way to redirect both the IPVS connection and
      the Netfilter's conntrack is to drop the SYN packet that
      hits existing connection, to wait for the next jiffie
      to expire the old connection and its conntrack and to rely
      on client's retransmission to create new connection as
      usually.
      
      Jiri Bohac provided a fix that drops all SYNs on rescheduling,
      I extended his patch to do such drops only for connections
      that use conntrack. Here is the original report from Jiri Bohac:
      
      Since commit dc7b3eb9 ("ipvs: Fix reuse connection if real server
      is dead"), new connections to dead servers are redistributed
      immediately to new servers.  The old connection is expired using
      ip_vs_conn_expire_now() which sets the connection timer to expire
      immediately.
      
      However, before the timer callback, ip_vs_conn_expire(), is run
      to clean the connection's conntrack entry, the new redistributed
      connection may already be established and its conntrack removed
      instead.
      
      Fix this by dropping the first packet of the new connection
      instead, like we do when the destination server is not available.
      The timer will have deleted the old conntrack entry long before
      the first packet of the new connection is retransmitted.
      
      Fixes: dc7b3eb9 ("ipvs: Fix reuse connection if real server is dead")
      Signed-off-by: NJiri Bohac <jbohac@suse.cz>
      Signed-off-by: NJulian Anastasov <ja@ssi.bg>
      Signed-off-by: NSimon Horman <horms@verge.net.au>
      f719e375
  5. 24 9月, 2015 32 次提交
  6. 17 9月, 2015 1 次提交
  7. 01 9月, 2015 2 次提交