Second Round of IPVS updates for v3.13

Some SCTP changes by Daniel Borkman.

* Correct verdict assignments in sctp_conn_schedule

  This is a bug fix for incorrect handling of the error case
  where skb_header_pointer() fails.

  It appears that this problem has been present since SCTP was added
  to IPVS in v2.6.34.

* Do not recalculate SCTP checksum if ports don't change

  This is an enhancement which should lead to increased performance
  in some cases.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)

iQIcBAABAgAGBQJScFqMAAoJENfPZGlqN0++uP4QAKQFI4UNQYnnve0acOyGGXE+
brIwrBhn3sddjCBhvYMAItDq5eVCfVtFonJ1qcle9bJzYjS5/yQoKk+1wT92WTQd
cKR07UtdfAKK3ml0MwD/qwwYFfNgSYE4mxiAoSkYwJ27k61zP1Ob85aOxQv+7e2F
LmyrpbuV9qiLIPvtDIeVpgI/+V9OGJSXL2DkXaFCTfUqQztBSrnq4FHPDLSyGcDT
Aw1JS58A5QJyqG63Z+ga0gzI4zKhQPlfob7flw9n7gooQOGdz9x+ngoLtpWoRYqS
NTZFd4TtY/mGeen6/slcYjfntU5obIM/opR/sDhEgr33VaEHUlMpATCUnTnbzrfq
gMydzlFPwWO3gz9/wCw6XK0DuAT6qH+ZKeOKcDY2umLg3o1LEhuq2CxVjClnFCOW
DCnPSq2b6Vq+p7OXWm3or7UNQ58PrBVpDGs60z8HaPRFr2pvwxQzShXIJ1++rPcq
/s3dYZWEIbAuwdhoS9ttQu9Tn0CO+EVay0iau0stqW4ioEvALByodcUmgro7mcTy
/+NdfPOfLR6wZd4g1dq1nsGFGcYVePyJLOnkSCgKTz97gnN6H1aGGc3Fhrhtzeni
eEjR5CPFTUnsn4+iP0Uc04aSyshe72qIY/vWdB/++cRa/d2dU3Rg05kqA4WM7T3J
6D3cO0tOs6tJn6NMqOPG
=qYUw
-----END PGP SIGNATURE-----
net: ipvs: sctp: do not recalc sctp csum when ports didn't change

Unlike UDP or TCP, we do not take the pseudo-header into
account in SCTP checksums. So in case port mapping is the
very same, we do not need to recalculate the whole SCTP
checksum in software, which is very expensive.

Also, similarly as in TCP, take into account when a private
helper mangled the packet. In that case, we also need to
recalculate the checksum even if ports might be same.

Thanks for feedback regarding skb->ip_summed checks from
Julian Anastasov; here's a discussion on these checks for
snat and dnat:

* For snat_handler(), we can see CHECKSUM_PARTIAL from
  virtual devices, and from LOCAL_OUT, otherwise it
  should be CHECKSUM_UNNECESSARY. In general, in snat it
  is more complex. skb contains the original route and
  ip_vs_route_me_harder() can change the route after
  snat_handler. So, for locally generated replies from
  local server we can not preserve the CHECKSUM_PARTIAL
  mode. It is an chicken or egg dilemma: snat_handler
  needs the device after rerouting (to check for
  NETIF_F_SCTP_CSUM), while ip_route_me_harder() wants
  the snat_handler() to put the new saddr for proper
  rerouting.

* For dnat_handler(), we should not see CHECKSUM_COMPLETE
  for SCTP, in fact the small set of drivers that support
  SCTP offloading return CHECKSUM_UNNECESSARY on correctly
  received SCTP csum. We can see CHECKSUM_PARTIAL from
  local stack or received from virtual drivers. The idea is
  that SCTP decides to avoid csum calculation if hardware
  supports offloading. IPVS can change the device after
  rerouting to real server but we can preserve the
  CHECKSUM_PARTIAL mode if the new device supports
  offloading too. This works because skb dst is changed
  before dnat_handler and we see the new device. So, checks
  in the 'if' part will decide whether it is ok to keep
  CHECKSUM_PARTIAL for the output. If the packet was with
  CHECKSUM_NONE, hence we deal with unknown checksum. As we
  recalculate the sum for IP header in all cases, it should
  be safe to use CHECKSUM_UNNECESSARY. We can forward wrong
  checksum in this case (without cp->app). In case of
  CHECKSUM_UNNECESSARY, the csum was valid on receive.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
1 file changed