summaryrefslogtreecommitdiff
path: root/include/net/ip.h
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2018-07-06 10:12:54 -0400
committerDavid S. Miller <davem@davemloft.net>2018-07-07 10:58:49 +0900
commit351782067b6be81879b0af0daf7bd3acbb32d986 (patch)
tree636d78515302aeb0e8513fe7763d8e1ba0872d6c /include/net/ip.h
parentab8565af68001ac5f9331daa311938ead3eb5636 (diff)
ipv4: ipcm_cookie initializers
Initialize the cookie in one location to reduce code duplication and avoid bugs from inconsistent initialization, such as that fixed in commit 9887cba19978 ("ip: limit use of gso_size to udp"). Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ip.h')
-rw-r--r--include/net/ip.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/net/ip.h b/include/net/ip.h
index 99d1b835d2aa..6db23bf1e5eb 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -79,6 +79,21 @@ struct ipcm_cookie {
__u16 gso_size;
};
+static inline void ipcm_init(struct ipcm_cookie *ipcm)
+{
+ *ipcm = (struct ipcm_cookie) { .tos = -1 };
+}
+
+static inline void ipcm_init_sk(struct ipcm_cookie *ipcm,
+ const struct inet_sock *inet)
+{
+ ipcm_init(ipcm);
+
+ ipcm->sockc.tsflags = inet->sk.sk_tsflags;
+ ipcm->oif = inet->sk.sk_bound_dev_if;
+ ipcm->addr = inet->inet_saddr;
+}
+
#define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb))
#define PKTINFO_SKB_CB(skb) ((struct in_pktinfo *)((skb)->cb))