mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmInmkMACgkQONu9yGCS aT6xgg//ZTjCvlkKgNuRUEKpfajomlq1zldwOmuxbb5fWtLPWiwKsZVriwaFxboQ b7QMN+VuW/J3MV3NAzaYoP7hDfX0hZNAhfHW0VD8+f+Ku62IZ06slJ48DiNRDEsG FNlPlbO/Fm42Jn99q4NJltVC0kjb9hX6iL96fQJH/y/KdkJvvnDfteWdr88ZBuKk 7cKl+pCHquAXoYlUb4y/H2IYwZLxtf01Y36vg/Q6ANK7KLOwbex3x0zzDF7MsVrD KsoV9e9YgPv/XT32EoizJMIcFFdRX8uXy5Tb/B3dpbaSfawWjdveJMhQ/skZAbCn ndE6M6gCWWwpMKR0X/fPYRQuy6Gn2ihqaDWNIzxucNrjiUQn3nbAIwnGTUcFQpw4 cm7jbpm+WvfU2cO2PfKkq2GCqBqkF7JtUm7X9kn+KwISXgRRd5UGUWIONXKiNl36 z29Ztf6RnR7CKMduVBczPbdggYuYDIms+2FMIziKbAXqjBDuFyh7RH4gv5a+/ML6 v1SHkKu8wb8+E/oCjnVp2XvDRnFnpwyR11DHuQ1Z0J2BtoK3Z62OkG01hoTrjJBO y/woxLDLHEg8pklSzO+zsXcROlx95SydauPR0xAXn0YN/J2khKvejj7SC5m33F6o DXzoRd0xHZaKPNjIZRQpvRVW2ca29+GMGGjgHMQF/t2FyGpdViQ= =D4n3 -----END PGP SIGNATURE----- Merge 4.14.270 into android-4.14-stable Changes in 4.14.270 mac80211_hwsim: report NOACK frames in tx_status mac80211_hwsim: initialize ieee80211_tx_info at hw_scan_work i2c: bcm2835: Avoid clock stretching timeouts Input: clear BTN_RIGHT/MIDDLE on buttonpads cifs: fix double free race when mount fails in cifs_get_root() dmaengine: shdma: Fix runtime PM imbalance on error i2c: cadence: allow COMPILE_TEST i2c: qup: allow COMPILE_TEST net: usb: cdc_mbim: avoid altsetting toggling for Telit FN990 usb: gadget: don't release an existing dev->buf usb: gadget: clear related members when goto fail ata: pata_hpt37x: fix PCI clock detection ALSA: intel_hdmi: Fix reference to PCM buffer address ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min xfrm: fix MTU regression netfilter: fix use-after-free in __nf_register_net_hook() xfrm: enforce validity of offload input flags netfilter: nf_queue: don't assume sk is full socket netfilter: nf_queue: fix possible use-after-free batman-adv: Request iflink once in batadv-on-batadv check batman-adv: Request iflink once in batadv_get_real_netdevice batman-adv: Don't expect inter-netns unique iflink indices net: dcb: flush lingering app table entries for unregistered devices net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error generated by client net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error cause by server firmware: Fix a reference count leak. firmware: qemu_fw_cfg: fix kobject leak in probe error path mac80211: fix forwarded mesh frames AC & queue selection net: stmmac: fix return value of __setup handler net: sxgbe: fix return value of __setup handler net: arcnet: com20020: Fix null-ptr-deref in com20020pci_probe() efivars: Respect "block" flag in efivar_entry_set_safe() can: gs_usb: change active_channels's type from atomic_t to u8 ARM: 9182/1: mmu: fix returns from early_param() and __setup() functions soc: fsl: qe: Check of ioremap return value net: chelsio: cxgb3: check the return value of pci_find_capability() nl80211: Handle nla_memdup failures in handle_nan_filter Input: elan_i2c - move regulator_[en|dis]able() out of elan_[en|dis]able_power() Input: elan_i2c - fix regulator enable count imbalance after suspend/resume HID: add mapping for KEY_ALL_APPLICATIONS memfd: fix F_SEAL_WRITE after shmem huge page allocated net: dcb: disable softirqs in dcbnl_flush_dev() hamradio: fix macro redefine warning Linux 4.14.270 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I347904c6d8e62225c5d0b642cddec4baeca819f2
209 lines
4.6 KiB
C
209 lines
4.6 KiB
C
/*
|
|
* xfrm_device.c - IPsec device offloading code.
|
|
*
|
|
* Copyright (c) 2015 secunet Security Networks AG
|
|
*
|
|
* Author:
|
|
* Steffen Klassert <steffen.klassert@secunet.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#include <linux/errno.h>
|
|
#include <linux/module.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/spinlock.h>
|
|
#include <net/dst.h>
|
|
#include <net/xfrm.h>
|
|
#include <linux/notifier.h>
|
|
|
|
#ifdef CONFIG_XFRM_OFFLOAD
|
|
int validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t features)
|
|
{
|
|
int err;
|
|
struct xfrm_state *x;
|
|
struct xfrm_offload *xo = xfrm_offload(skb);
|
|
|
|
if (skb_is_gso(skb))
|
|
return 0;
|
|
|
|
if (xo) {
|
|
x = skb->sp->xvec[skb->sp->len - 1];
|
|
if (xo->flags & XFRM_GRO || x->xso.flags & XFRM_OFFLOAD_INBOUND)
|
|
return 0;
|
|
|
|
x->outer_mode->xmit(x, skb);
|
|
|
|
err = x->type_offload->xmit(x, skb, features);
|
|
if (err) {
|
|
XFRM_INC_STATS(xs_net(x), LINUX_MIB_XFRMOUTSTATEPROTOERROR);
|
|
return err;
|
|
}
|
|
|
|
skb_push(skb, skb->data - skb_mac_header(skb));
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(validate_xmit_xfrm);
|
|
|
|
int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
|
|
struct xfrm_user_offload *xuo)
|
|
{
|
|
int err;
|
|
struct dst_entry *dst;
|
|
struct net_device *dev;
|
|
struct xfrm_state_offload *xso = &x->xso;
|
|
xfrm_address_t *saddr;
|
|
xfrm_address_t *daddr;
|
|
|
|
if (!x->type_offload)
|
|
return -EINVAL;
|
|
|
|
/* We don't yet support UDP encapsulation, TFC padding and ESN. */
|
|
if (x->encap || x->tfcpad || (x->props.flags & XFRM_STATE_ESN))
|
|
return 0;
|
|
|
|
if (xuo->flags & ~(XFRM_OFFLOAD_IPV6 | XFRM_OFFLOAD_INBOUND))
|
|
return -EINVAL;
|
|
|
|
dev = dev_get_by_index(net, xuo->ifindex);
|
|
if (!dev) {
|
|
if (!(xuo->flags & XFRM_OFFLOAD_INBOUND)) {
|
|
saddr = &x->props.saddr;
|
|
daddr = &x->id.daddr;
|
|
} else {
|
|
saddr = &x->id.daddr;
|
|
daddr = &x->props.saddr;
|
|
}
|
|
|
|
dst = __xfrm_dst_lookup(net, 0, 0, saddr, daddr,
|
|
x->props.family,
|
|
xfrm_smark_get(0, x));
|
|
if (IS_ERR(dst))
|
|
return 0;
|
|
|
|
dev = dst->dev;
|
|
|
|
dev_hold(dev);
|
|
dst_release(dst);
|
|
}
|
|
|
|
if (!dev->xfrmdev_ops || !dev->xfrmdev_ops->xdo_dev_state_add) {
|
|
xso->dev = NULL;
|
|
dev_put(dev);
|
|
return 0;
|
|
}
|
|
|
|
xso->dev = dev;
|
|
xso->num_exthdrs = 1;
|
|
/* Don't forward bit that is not implemented */
|
|
xso->flags = xuo->flags & ~XFRM_OFFLOAD_IPV6;
|
|
|
|
err = dev->xfrmdev_ops->xdo_dev_state_add(x);
|
|
if (err) {
|
|
dev_put(dev);
|
|
return err;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(xfrm_dev_state_add);
|
|
|
|
bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
|
|
{
|
|
int mtu;
|
|
struct dst_entry *dst = skb_dst(skb);
|
|
struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
|
|
struct net_device *dev = x->xso.dev;
|
|
|
|
if (!x->type_offload || x->encap)
|
|
return false;
|
|
|
|
if ((x->xso.offload_handle && (dev == dst->path->dev)) &&
|
|
!dst->child->xfrm && x->type->get_mtu) {
|
|
mtu = x->type->get_mtu(x, xdst->child_mtu_cached);
|
|
|
|
if (skb->len <= mtu)
|
|
goto ok;
|
|
|
|
if (skb_is_gso(skb) && skb_gso_validate_mtu(skb, mtu))
|
|
goto ok;
|
|
}
|
|
|
|
return false;
|
|
|
|
ok:
|
|
if (dev && dev->xfrmdev_ops && dev->xfrmdev_ops->xdo_dev_offload_ok)
|
|
return x->xso.dev->xfrmdev_ops->xdo_dev_offload_ok(skb, x);
|
|
|
|
return true;
|
|
}
|
|
EXPORT_SYMBOL_GPL(xfrm_dev_offload_ok);
|
|
#endif
|
|
|
|
static int xfrm_dev_register(struct net_device *dev)
|
|
{
|
|
if ((dev->features & NETIF_F_HW_ESP) && !dev->xfrmdev_ops)
|
|
return NOTIFY_BAD;
|
|
if ((dev->features & NETIF_F_HW_ESP_TX_CSUM) &&
|
|
!(dev->features & NETIF_F_HW_ESP))
|
|
return NOTIFY_BAD;
|
|
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
static int xfrm_dev_feat_change(struct net_device *dev)
|
|
{
|
|
if ((dev->features & NETIF_F_HW_ESP) && !dev->xfrmdev_ops)
|
|
return NOTIFY_BAD;
|
|
else if (!(dev->features & NETIF_F_HW_ESP))
|
|
dev->xfrmdev_ops = NULL;
|
|
|
|
if ((dev->features & NETIF_F_HW_ESP_TX_CSUM) &&
|
|
!(dev->features & NETIF_F_HW_ESP))
|
|
return NOTIFY_BAD;
|
|
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
static int xfrm_dev_down(struct net_device *dev)
|
|
{
|
|
if (dev->features & NETIF_F_HW_ESP)
|
|
xfrm_dev_state_flush(dev_net(dev), dev, true);
|
|
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr)
|
|
{
|
|
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
|
|
|
|
switch (event) {
|
|
case NETDEV_REGISTER:
|
|
return xfrm_dev_register(dev);
|
|
|
|
case NETDEV_FEAT_CHANGE:
|
|
return xfrm_dev_feat_change(dev);
|
|
|
|
case NETDEV_DOWN:
|
|
case NETDEV_UNREGISTER:
|
|
return xfrm_dev_down(dev);
|
|
}
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
static struct notifier_block xfrm_dev_notifier = {
|
|
.notifier_call = xfrm_dev_event,
|
|
};
|
|
|
|
void __net_init xfrm_dev_init(void)
|
|
{
|
|
register_netdevice_notifier(&xfrm_dev_notifier);
|
|
}
|