diff options
author | Greg Kroah-Hartman <gregkh@google.com> | 2020-05-27 16:54:34 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2020-05-27 16:54:34 +0200 |
commit | aa9dc801acdcb14a7793e759596c97c61b3d9dee (patch) | |
tree | 6fd6c85949905042795eeea01d9e502fcd15ec55 /net/socket.c | |
parent | 53454c3459bc25f3678f0ec9632609082685c766 (diff) | |
parent | 646cdb183bb780e11e0ad4534d9054f77c31c8dc (diff) |
Merge 4.4.225 into android-4.4-p
Changes in 4.4.225
igb: use igb_adapter->io_addr instead of e1000_hw->hw_addr
padata: Remove unused but set variables
padata: get_next is never NULL
padata: ensure the reorder timer callback runs on the correct CPU
padata: ensure padata_do_serial() runs on the correct CPU
evm: Check also if *tfm is an error pointer in init_desc()
fix multiplication overflow in copy_fdtable()
HID: multitouch: add eGalaxTouch P80H84 support
ceph: fix double unlock in handle_cap_export()
USB: core: Fix misleading driver bug report
platform/x86: asus-nb-wmi: Do not load on Asus T100TA and T200TA
ARM: futex: Address build warning
media: Fix media_open() to clear filp->private_data in error leg
drivers/media/media-devnode: clear private_data before put_device()
media-devnode: add missing mutex lock in error handler
media-devnode: fix namespace mess
media-device: dynamically allocate struct media_devnode
media: fix use-after-free in cdev_put() when app exits after driver unbind
media: fix media devnode ioctl/syscall and unregister race
i2c: dev: switch from register_chrdev to cdev API
i2c: dev: don't start function name with 'return'
i2c: dev: use after free in detach
i2c-dev: don't get i2c adapter via i2c_dev
i2c: dev: Fix the race between the release of i2c_dev and cdev
padata: set cpu_index of unused CPUs to -1
sched/fair, cpumask: Export for_each_cpu_wrap()
padata: Replace delayed timer with immediate workqueue in padata_reorder
padata: initialize pd->cpu with effective cpumask
padata: purge get_cpu and reorder_via_wq from padata_do_serial
ALSA: pcm: fix incorrect hw_base increase
ext4: lock the xattr block before checksuming it
platform/x86: alienware-wmi: fix kfree on potentially uninitialized pointer
libnvdimm/btt: Remove unnecessary code in btt_freelist_init
l2tp: lock socket before checking flags in connect()
l2tp: fix racy socket lookup in l2tp_ip and l2tp_ip6 bind()
l2tp: hold session while sending creation notifications
l2tp: take a reference on sessions used in genetlink handlers
l2tp: don't use l2tp_tunnel_find() in l2tp_ip and l2tp_ip6
net: l2tp: export debug flags to UAPI
net: l2tp: deprecate PPPOL2TP_MSG_* in favour of L2TP_MSG_*
net: l2tp: ppp: change PPPOL2TP_MSG_* => L2TP_MSG_*
New kernel function to get IP overhead on a socket.
L2TP:Adjust intf MTU, add underlay L3, L2 hdrs.
l2tp: remove useless duplicate session detection in l2tp_netlink
l2tp: remove l2tp_session_find()
l2tp: define parameters of l2tp_session_get*() as "const"
l2tp: define parameters of l2tp_tunnel_find*() as "const"
l2tp: initialise session's refcount before making it reachable
l2tp: hold tunnel while looking up sessions in l2tp_netlink
l2tp: hold tunnel while processing genl delete command
l2tp: hold tunnel while handling genl tunnel updates
l2tp: hold tunnel while handling genl TUNNEL_GET commands
l2tp: hold tunnel used while creating sessions with netlink
l2tp: prevent creation of sessions on terminated tunnels
l2tp: pass tunnel pointer to ->session_create()
l2tp: fix l2tp_eth module loading
l2tp: don't register sessions in l2tp_session_create()
l2tp: initialise l2tp_eth sessions before registering them
l2tp: protect sock pointer of struct pppol2tp_session with RCU
l2tp: initialise PPP sessions before registering them
Revert "gfs2: Don't demote a glock until its revokes are written"
staging: iio: ad2s1210: Fix SPI reading
mei: release me_cl object reference
iio: sca3000: Remove an erroneous 'get_device()'
l2tp: device MTU setup, tunnel socket needs a lock
cpumask: Make for_each_cpu_wrap() available on UP as well
Linux 4.4.225
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I87dc4ca47f34d594fff7c1da28c7a4596659c029
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/net/socket.c b/net/socket.c index d700d23858a6..733233ba3144 100644 --- a/net/socket.c +++ b/net/socket.c @@ -3331,3 +3331,49 @@ int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how) return sock->ops->shutdown(sock, how); } EXPORT_SYMBOL(kernel_sock_shutdown); + +/* This routine returns the IP overhead imposed by a socket i.e. + * the length of the underlying IP header, depending on whether + * this is an IPv4 or IPv6 socket and the length from IP options turned + * on at the socket. Assumes that the caller has a lock on the socket. + */ +u32 kernel_sock_ip_overhead(struct sock *sk) +{ + struct inet_sock *inet; + struct ip_options_rcu *opt; + u32 overhead = 0; + bool owned_by_user; +#if IS_ENABLED(CONFIG_IPV6) + struct ipv6_pinfo *np; + struct ipv6_txoptions *optv6 = NULL; +#endif /* IS_ENABLED(CONFIG_IPV6) */ + + if (!sk) + return overhead; + + owned_by_user = sock_owned_by_user(sk); + switch (sk->sk_family) { + case AF_INET: + inet = inet_sk(sk); + overhead += sizeof(struct iphdr); + opt = rcu_dereference_protected(inet->inet_opt, + owned_by_user); + if (opt) + overhead += opt->opt.optlen; + return overhead; +#if IS_ENABLED(CONFIG_IPV6) + case AF_INET6: + np = inet6_sk(sk); + overhead += sizeof(struct ipv6hdr); + if (np) + optv6 = rcu_dereference_protected(np->opt, + owned_by_user); + if (optv6) + overhead += (optv6->opt_flen + optv6->opt_nflen); + return overhead; +#endif /* IS_ENABLED(CONFIG_IPV6) */ + default: /* Returns 0 overhead if the socket is not ipv4 or ipv6 */ + return overhead; + } +} +EXPORT_SYMBOL(kernel_sock_ip_overhead); |