summaryrefslogtreecommitdiffstats
path: root/net/key
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-06-16 08:29:21 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-16 11:48:39 -0400
commit4df864c1d9afb46e2461a9f808d9f11a42d31bad (patch)
tree07e7b3d16b161e0d199c5b8116df277798566e4f /net/key
parent59ae1d127ac0ae404baf414c434ba2651b793f46 (diff)
networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *, and in many places that means casts are required, more often than not. Make these functions (skb_put, __skb_put and pskb_put) return void * and remove all the casts across the tree, adding a (u8 *) cast only where the unsigned char pointer was used directly, all done with the following spatch: @@ expression SKB, LEN; typedef u8; identifier fn = { skb_put, __skb_put }; @@ - *(fn(SKB, LEN)) + *(u8 *)fn(SKB, LEN) @@ expression E, SKB, LEN; identifier fn = { skb_put, __skb_put }; type T; @@ - E = ((T *)(fn(SKB, LEN))) + E = fn(SKB, LEN) which actually doesn't cover pskb_put since there are only three users overall. A handful of stragglers were converted manually, notably a macro in drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many instances in net/bluetooth/hci_sock.c. In the former file, I also had to fix one whitespace problem spatch introduced. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/key')
-rw-r--r--net/key/af_key.c116
1 files changed, 50 insertions, 66 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 3ebb4268973b..daa4e90dc4db 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -349,7 +349,7 @@ static int pfkey_error(const struct sadb_msg *orig, int err, struct sock *sk)
349 err = EINVAL; 349 err = EINVAL;
350 BUG_ON(err <= 0 || err >= 256); 350 BUG_ON(err <= 0 || err >= 256);
351 351
352 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); 352 hdr = skb_put(skb, sizeof(struct sadb_msg));
353 pfkey_hdr_dup(hdr, orig); 353 pfkey_hdr_dup(hdr, orig);
354 hdr->sadb_msg_errno = (uint8_t) err; 354 hdr->sadb_msg_errno = (uint8_t) err;
355 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / 355 hdr->sadb_msg_len = (sizeof(struct sadb_msg) /
@@ -810,12 +810,12 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
810 return ERR_PTR(-ENOBUFS); 810 return ERR_PTR(-ENOBUFS);
811 811
812 /* call should fill header later */ 812 /* call should fill header later */
813 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); 813 hdr = skb_put(skb, sizeof(struct sadb_msg));
814 memset(hdr, 0, size); /* XXX do we need this ? */ 814 memset(hdr, 0, size); /* XXX do we need this ? */
815 hdr->sadb_msg_len = size / sizeof(uint64_t); 815 hdr->sadb_msg_len = size / sizeof(uint64_t);
816 816
817 /* sa */ 817 /* sa */
818 sa = (struct sadb_sa *) skb_put(skb, sizeof(struct sadb_sa)); 818 sa = skb_put(skb, sizeof(struct sadb_sa));
819 sa->sadb_sa_len = sizeof(struct sadb_sa)/sizeof(uint64_t); 819 sa->sadb_sa_len = sizeof(struct sadb_sa)/sizeof(uint64_t);
820 sa->sadb_sa_exttype = SADB_EXT_SA; 820 sa->sadb_sa_exttype = SADB_EXT_SA;
821 sa->sadb_sa_spi = x->id.spi; 821 sa->sadb_sa_spi = x->id.spi;
@@ -862,8 +862,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
862 862
863 /* hard time */ 863 /* hard time */
864 if (hsc & 2) { 864 if (hsc & 2) {
865 lifetime = (struct sadb_lifetime *) skb_put(skb, 865 lifetime = skb_put(skb, sizeof(struct sadb_lifetime));
866 sizeof(struct sadb_lifetime));
867 lifetime->sadb_lifetime_len = 866 lifetime->sadb_lifetime_len =
868 sizeof(struct sadb_lifetime)/sizeof(uint64_t); 867 sizeof(struct sadb_lifetime)/sizeof(uint64_t);
869 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_HARD; 868 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_HARD;
@@ -874,8 +873,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
874 } 873 }
875 /* soft time */ 874 /* soft time */
876 if (hsc & 1) { 875 if (hsc & 1) {
877 lifetime = (struct sadb_lifetime *) skb_put(skb, 876 lifetime = skb_put(skb, sizeof(struct sadb_lifetime));
878 sizeof(struct sadb_lifetime));
879 lifetime->sadb_lifetime_len = 877 lifetime->sadb_lifetime_len =
880 sizeof(struct sadb_lifetime)/sizeof(uint64_t); 878 sizeof(struct sadb_lifetime)/sizeof(uint64_t);
881 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_SOFT; 879 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_SOFT;
@@ -885,8 +883,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
885 lifetime->sadb_lifetime_usetime = x->lft.soft_use_expires_seconds; 883 lifetime->sadb_lifetime_usetime = x->lft.soft_use_expires_seconds;
886 } 884 }
887 /* current time */ 885 /* current time */
888 lifetime = (struct sadb_lifetime *) skb_put(skb, 886 lifetime = skb_put(skb, sizeof(struct sadb_lifetime));
889 sizeof(struct sadb_lifetime));
890 lifetime->sadb_lifetime_len = 887 lifetime->sadb_lifetime_len =
891 sizeof(struct sadb_lifetime)/sizeof(uint64_t); 888 sizeof(struct sadb_lifetime)/sizeof(uint64_t);
892 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_CURRENT; 889 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_CURRENT;
@@ -895,8 +892,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
895 lifetime->sadb_lifetime_addtime = x->curlft.add_time; 892 lifetime->sadb_lifetime_addtime = x->curlft.add_time;
896 lifetime->sadb_lifetime_usetime = x->curlft.use_time; 893 lifetime->sadb_lifetime_usetime = x->curlft.use_time;
897 /* src address */ 894 /* src address */
898 addr = (struct sadb_address*) skb_put(skb, 895 addr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);
899 sizeof(struct sadb_address)+sockaddr_size);
900 addr->sadb_address_len = 896 addr->sadb_address_len =
901 (sizeof(struct sadb_address)+sockaddr_size)/ 897 (sizeof(struct sadb_address)+sockaddr_size)/
902 sizeof(uint64_t); 898 sizeof(uint64_t);
@@ -915,8 +911,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
915 BUG(); 911 BUG();
916 912
917 /* dst address */ 913 /* dst address */
918 addr = (struct sadb_address*) skb_put(skb, 914 addr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);
919 sizeof(struct sadb_address)+sockaddr_size);
920 addr->sadb_address_len = 915 addr->sadb_address_len =
921 (sizeof(struct sadb_address)+sockaddr_size)/ 916 (sizeof(struct sadb_address)+sockaddr_size)/
922 sizeof(uint64_t); 917 sizeof(uint64_t);
@@ -933,8 +928,8 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
933 928
934 if (!xfrm_addr_equal(&x->sel.saddr, &x->props.saddr, 929 if (!xfrm_addr_equal(&x->sel.saddr, &x->props.saddr,
935 x->props.family)) { 930 x->props.family)) {
936 addr = (struct sadb_address*) skb_put(skb, 931 addr = skb_put(skb,
937 sizeof(struct sadb_address)+sockaddr_size); 932 sizeof(struct sadb_address) + sockaddr_size);
938 addr->sadb_address_len = 933 addr->sadb_address_len =
939 (sizeof(struct sadb_address)+sockaddr_size)/ 934 (sizeof(struct sadb_address)+sockaddr_size)/
940 sizeof(uint64_t); 935 sizeof(uint64_t);
@@ -951,8 +946,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
951 946
952 /* auth key */ 947 /* auth key */
953 if (add_keys && auth_key_size) { 948 if (add_keys && auth_key_size) {
954 key = (struct sadb_key *) skb_put(skb, 949 key = skb_put(skb, sizeof(struct sadb_key) + auth_key_size);
955 sizeof(struct sadb_key)+auth_key_size);
956 key->sadb_key_len = (sizeof(struct sadb_key) + auth_key_size) / 950 key->sadb_key_len = (sizeof(struct sadb_key) + auth_key_size) /
957 sizeof(uint64_t); 951 sizeof(uint64_t);
958 key->sadb_key_exttype = SADB_EXT_KEY_AUTH; 952 key->sadb_key_exttype = SADB_EXT_KEY_AUTH;
@@ -962,8 +956,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
962 } 956 }
963 /* encrypt key */ 957 /* encrypt key */
964 if (add_keys && encrypt_key_size) { 958 if (add_keys && encrypt_key_size) {
965 key = (struct sadb_key *) skb_put(skb, 959 key = skb_put(skb, sizeof(struct sadb_key) + encrypt_key_size);
966 sizeof(struct sadb_key)+encrypt_key_size);
967 key->sadb_key_len = (sizeof(struct sadb_key) + 960 key->sadb_key_len = (sizeof(struct sadb_key) +
968 encrypt_key_size) / sizeof(uint64_t); 961 encrypt_key_size) / sizeof(uint64_t);
969 key->sadb_key_exttype = SADB_EXT_KEY_ENCRYPT; 962 key->sadb_key_exttype = SADB_EXT_KEY_ENCRYPT;
@@ -974,7 +967,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
974 } 967 }
975 968
976 /* sa */ 969 /* sa */
977 sa2 = (struct sadb_x_sa2 *) skb_put(skb, sizeof(struct sadb_x_sa2)); 970 sa2 = skb_put(skb, sizeof(struct sadb_x_sa2));
978 sa2->sadb_x_sa2_len = sizeof(struct sadb_x_sa2)/sizeof(uint64_t); 971 sa2->sadb_x_sa2_len = sizeof(struct sadb_x_sa2)/sizeof(uint64_t);
979 sa2->sadb_x_sa2_exttype = SADB_X_EXT_SA2; 972 sa2->sadb_x_sa2_exttype = SADB_X_EXT_SA2;
980 if ((mode = pfkey_mode_from_xfrm(x->props.mode)) < 0) { 973 if ((mode = pfkey_mode_from_xfrm(x->props.mode)) < 0) {
@@ -992,7 +985,7 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
992 struct sadb_x_nat_t_port *n_port; 985 struct sadb_x_nat_t_port *n_port;
993 986
994 /* type */ 987 /* type */
995 n_type = (struct sadb_x_nat_t_type*) skb_put(skb, sizeof(*n_type)); 988 n_type = skb_put(skb, sizeof(*n_type));
996 n_type->sadb_x_nat_t_type_len = sizeof(*n_type)/sizeof(uint64_t); 989 n_type->sadb_x_nat_t_type_len = sizeof(*n_type)/sizeof(uint64_t);
997 n_type->sadb_x_nat_t_type_exttype = SADB_X_EXT_NAT_T_TYPE; 990 n_type->sadb_x_nat_t_type_exttype = SADB_X_EXT_NAT_T_TYPE;
998 n_type->sadb_x_nat_t_type_type = natt->encap_type; 991 n_type->sadb_x_nat_t_type_type = natt->encap_type;
@@ -1001,14 +994,14 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
1001 n_type->sadb_x_nat_t_type_reserved[2] = 0; 994 n_type->sadb_x_nat_t_type_reserved[2] = 0;
1002 995
1003 /* source port */ 996 /* source port */
1004 n_port = (struct sadb_x_nat_t_port*) skb_put(skb, sizeof (*n_port)); 997 n_port = skb_put(skb, sizeof(*n_port));
1005 n_port->sadb_x_nat_t_port_len = sizeof(*n_port)/sizeof(uint64_t); 998 n_port->sadb_x_nat_t_port_len = sizeof(*n_port)/sizeof(uint64_t);
1006 n_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_SPORT; 999 n_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_SPORT;
1007 n_port->sadb_x_nat_t_port_port = natt->encap_sport; 1000 n_port->sadb_x_nat_t_port_port = natt->encap_sport;
1008 n_port->sadb_x_nat_t_port_reserved = 0; 1001 n_port->sadb_x_nat_t_port_reserved = 0;
1009 1002
1010 /* dest port */ 1003 /* dest port */
1011 n_port = (struct sadb_x_nat_t_port*) skb_put(skb, sizeof (*n_port)); 1004 n_port = skb_put(skb, sizeof(*n_port));
1012 n_port->sadb_x_nat_t_port_len = sizeof(*n_port)/sizeof(uint64_t); 1005 n_port->sadb_x_nat_t_port_len = sizeof(*n_port)/sizeof(uint64_t);
1013 n_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_DPORT; 1006 n_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_DPORT;
1014 n_port->sadb_x_nat_t_port_port = natt->encap_dport; 1007 n_port->sadb_x_nat_t_port_port = natt->encap_dport;
@@ -1017,8 +1010,8 @@ static struct sk_buff *__pfkey_xfrm_state2msg(const struct xfrm_state *x,
1017 1010
1018 /* security context */ 1011 /* security context */
1019 if (xfrm_ctx) { 1012 if (xfrm_ctx) {
1020 sec_ctx = (struct sadb_x_sec_ctx *) skb_put(skb, 1013 sec_ctx = skb_put(skb,
1021 sizeof(struct sadb_x_sec_ctx) + ctx_size); 1014 sizeof(struct sadb_x_sec_ctx) + ctx_size);
1022 sec_ctx->sadb_x_sec_len = 1015 sec_ctx->sadb_x_sec_len =
1023 (sizeof(struct sadb_x_sec_ctx) + ctx_size) / sizeof(uint64_t); 1016 (sizeof(struct sadb_x_sec_ctx) + ctx_size) / sizeof(uint64_t);
1024 sec_ctx->sadb_x_sec_exttype = SADB_X_EXT_SEC_CTX; 1017 sec_ctx->sadb_x_sec_exttype = SADB_X_EXT_SEC_CTX;
@@ -1617,7 +1610,7 @@ static struct sk_buff *compose_sadb_supported(const struct sadb_msg *orig,
1617 if (!skb) 1610 if (!skb)
1618 goto out_put_algs; 1611 goto out_put_algs;
1619 1612
1620 hdr = (struct sadb_msg *) skb_put(skb, sizeof(*hdr)); 1613 hdr = skb_put(skb, sizeof(*hdr));
1621 pfkey_hdr_dup(hdr, orig); 1614 pfkey_hdr_dup(hdr, orig);
1622 hdr->sadb_msg_errno = 0; 1615 hdr->sadb_msg_errno = 0;
1623 hdr->sadb_msg_len = len / sizeof(uint64_t); 1616 hdr->sadb_msg_len = len / sizeof(uint64_t);
@@ -1626,7 +1619,7 @@ static struct sk_buff *compose_sadb_supported(const struct sadb_msg *orig,
1626 struct sadb_supported *sp; 1619 struct sadb_supported *sp;
1627 struct sadb_alg *ap; 1620 struct sadb_alg *ap;
1628 1621
1629 sp = (struct sadb_supported *) skb_put(skb, auth_len); 1622 sp = skb_put(skb, auth_len);
1630 ap = (struct sadb_alg *) (sp + 1); 1623 ap = (struct sadb_alg *) (sp + 1);
1631 1624
1632 sp->sadb_supported_len = auth_len / sizeof(uint64_t); 1625 sp->sadb_supported_len = auth_len / sizeof(uint64_t);
@@ -1647,7 +1640,7 @@ static struct sk_buff *compose_sadb_supported(const struct sadb_msg *orig,
1647 struct sadb_supported *sp; 1640 struct sadb_supported *sp;
1648 struct sadb_alg *ap; 1641 struct sadb_alg *ap;
1649 1642
1650 sp = (struct sadb_supported *) skb_put(skb, enc_len); 1643 sp = skb_put(skb, enc_len);
1651 ap = (struct sadb_alg *) (sp + 1); 1644 ap = (struct sadb_alg *) (sp + 1);
1652 1645
1653 sp->sadb_supported_len = enc_len / sizeof(uint64_t); 1646 sp->sadb_supported_len = enc_len / sizeof(uint64_t);
@@ -1721,7 +1714,7 @@ static int key_notify_sa_flush(const struct km_event *c)
1721 skb = alloc_skb(sizeof(struct sadb_msg) + 16, GFP_ATOMIC); 1714 skb = alloc_skb(sizeof(struct sadb_msg) + 16, GFP_ATOMIC);
1722 if (!skb) 1715 if (!skb)
1723 return -ENOBUFS; 1716 return -ENOBUFS;
1724 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); 1717 hdr = skb_put(skb, sizeof(struct sadb_msg));
1725 hdr->sadb_msg_satype = pfkey_proto2satype(c->data.proto); 1718 hdr->sadb_msg_satype = pfkey_proto2satype(c->data.proto);
1726 hdr->sadb_msg_type = SADB_FLUSH; 1719 hdr->sadb_msg_type = SADB_FLUSH;
1727 hdr->sadb_msg_seq = c->seq; 1720 hdr->sadb_msg_seq = c->seq;
@@ -2046,12 +2039,11 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *
2046 size = pfkey_xfrm_policy2msg_size(xp); 2039 size = pfkey_xfrm_policy2msg_size(xp);
2047 2040
2048 /* call should fill header later */ 2041 /* call should fill header later */
2049 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); 2042 hdr = skb_put(skb, sizeof(struct sadb_msg));
2050 memset(hdr, 0, size); /* XXX do we need this ? */ 2043 memset(hdr, 0, size); /* XXX do we need this ? */
2051 2044
2052 /* src address */ 2045 /* src address */
2053 addr = (struct sadb_address*) skb_put(skb, 2046 addr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);
2054 sizeof(struct sadb_address)+sockaddr_size);
2055 addr->sadb_address_len = 2047 addr->sadb_address_len =
2056 (sizeof(struct sadb_address)+sockaddr_size)/ 2048 (sizeof(struct sadb_address)+sockaddr_size)/
2057 sizeof(uint64_t); 2049 sizeof(uint64_t);
@@ -2066,8 +2058,7 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *
2066 BUG(); 2058 BUG();
2067 2059
2068 /* dst address */ 2060 /* dst address */
2069 addr = (struct sadb_address*) skb_put(skb, 2061 addr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);
2070 sizeof(struct sadb_address)+sockaddr_size);
2071 addr->sadb_address_len = 2062 addr->sadb_address_len =
2072 (sizeof(struct sadb_address)+sockaddr_size)/ 2063 (sizeof(struct sadb_address)+sockaddr_size)/
2073 sizeof(uint64_t); 2064 sizeof(uint64_t);
@@ -2081,8 +2072,7 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *
2081 xp->family); 2072 xp->family);
2082 2073
2083 /* hard time */ 2074 /* hard time */
2084 lifetime = (struct sadb_lifetime *) skb_put(skb, 2075 lifetime = skb_put(skb, sizeof(struct sadb_lifetime));
2085 sizeof(struct sadb_lifetime));
2086 lifetime->sadb_lifetime_len = 2076 lifetime->sadb_lifetime_len =
2087 sizeof(struct sadb_lifetime)/sizeof(uint64_t); 2077 sizeof(struct sadb_lifetime)/sizeof(uint64_t);
2088 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_HARD; 2078 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_HARD;
@@ -2091,8 +2081,7 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *
2091 lifetime->sadb_lifetime_addtime = xp->lft.hard_add_expires_seconds; 2081 lifetime->sadb_lifetime_addtime = xp->lft.hard_add_expires_seconds;
2092 lifetime->sadb_lifetime_usetime = xp->lft.hard_use_expires_seconds; 2082 lifetime->sadb_lifetime_usetime = xp->lft.hard_use_expires_seconds;
2093 /* soft time */ 2083 /* soft time */
2094 lifetime = (struct sadb_lifetime *) skb_put(skb, 2084 lifetime = skb_put(skb, sizeof(struct sadb_lifetime));
2095 sizeof(struct sadb_lifetime));
2096 lifetime->sadb_lifetime_len = 2085 lifetime->sadb_lifetime_len =
2097 sizeof(struct sadb_lifetime)/sizeof(uint64_t); 2086 sizeof(struct sadb_lifetime)/sizeof(uint64_t);
2098 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_SOFT; 2087 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_SOFT;
@@ -2101,8 +2090,7 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *
2101 lifetime->sadb_lifetime_addtime = xp->lft.soft_add_expires_seconds; 2090 lifetime->sadb_lifetime_addtime = xp->lft.soft_add_expires_seconds;
2102 lifetime->sadb_lifetime_usetime = xp->lft.soft_use_expires_seconds; 2091 lifetime->sadb_lifetime_usetime = xp->lft.soft_use_expires_seconds;
2103 /* current time */ 2092 /* current time */
2104 lifetime = (struct sadb_lifetime *) skb_put(skb, 2093 lifetime = skb_put(skb, sizeof(struct sadb_lifetime));
2105 sizeof(struct sadb_lifetime));
2106 lifetime->sadb_lifetime_len = 2094 lifetime->sadb_lifetime_len =
2107 sizeof(struct sadb_lifetime)/sizeof(uint64_t); 2095 sizeof(struct sadb_lifetime)/sizeof(uint64_t);
2108 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_CURRENT; 2096 lifetime->sadb_lifetime_exttype = SADB_EXT_LIFETIME_CURRENT;
@@ -2111,7 +2099,7 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *
2111 lifetime->sadb_lifetime_addtime = xp->curlft.add_time; 2099 lifetime->sadb_lifetime_addtime = xp->curlft.add_time;
2112 lifetime->sadb_lifetime_usetime = xp->curlft.use_time; 2100 lifetime->sadb_lifetime_usetime = xp->curlft.use_time;
2113 2101
2114 pol = (struct sadb_x_policy *) skb_put(skb, sizeof(struct sadb_x_policy)); 2102 pol = skb_put(skb, sizeof(struct sadb_x_policy));
2115 pol->sadb_x_policy_len = sizeof(struct sadb_x_policy)/sizeof(uint64_t); 2103 pol->sadb_x_policy_len = sizeof(struct sadb_x_policy)/sizeof(uint64_t);
2116 pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY; 2104 pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
2117 pol->sadb_x_policy_type = IPSEC_POLICY_DISCARD; 2105 pol->sadb_x_policy_type = IPSEC_POLICY_DISCARD;
@@ -2139,7 +2127,7 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *
2139 } else { 2127 } else {
2140 size -= 2*socklen; 2128 size -= 2*socklen;
2141 } 2129 }
2142 rq = (void*)skb_put(skb, req_size); 2130 rq = skb_put(skb, req_size);
2143 pol->sadb_x_policy_len += req_size/8; 2131 pol->sadb_x_policy_len += req_size/8;
2144 memset(rq, 0, sizeof(*rq)); 2132 memset(rq, 0, sizeof(*rq));
2145 rq->sadb_x_ipsecrequest_len = req_size; 2133 rq->sadb_x_ipsecrequest_len = req_size;
@@ -2169,7 +2157,7 @@ static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *
2169 if ((xfrm_ctx = xp->security)) { 2157 if ((xfrm_ctx = xp->security)) {
2170 int ctx_size = pfkey_xfrm_policy2sec_ctx_size(xp); 2158 int ctx_size = pfkey_xfrm_policy2sec_ctx_size(xp);
2171 2159
2172 sec_ctx = (struct sadb_x_sec_ctx *) skb_put(skb, ctx_size); 2160 sec_ctx = skb_put(skb, ctx_size);
2173 sec_ctx->sadb_x_sec_len = ctx_size / sizeof(uint64_t); 2161 sec_ctx->sadb_x_sec_len = ctx_size / sizeof(uint64_t);
2174 sec_ctx->sadb_x_sec_exttype = SADB_X_EXT_SEC_CTX; 2162 sec_ctx->sadb_x_sec_exttype = SADB_X_EXT_SEC_CTX;
2175 sec_ctx->sadb_x_ctx_doi = xfrm_ctx->ctx_doi; 2163 sec_ctx->sadb_x_ctx_doi = xfrm_ctx->ctx_doi;
@@ -2733,7 +2721,7 @@ static int key_notify_policy_flush(const struct km_event *c)
2733 skb_out = alloc_skb(sizeof(struct sadb_msg) + 16, GFP_ATOMIC); 2721 skb_out = alloc_skb(sizeof(struct sadb_msg) + 16, GFP_ATOMIC);
2734 if (!skb_out) 2722 if (!skb_out)
2735 return -ENOBUFS; 2723 return -ENOBUFS;
2736 hdr = (struct sadb_msg *) skb_put(skb_out, sizeof(struct sadb_msg)); 2724 hdr = skb_put(skb_out, sizeof(struct sadb_msg));
2737 hdr->sadb_msg_type = SADB_X_SPDFLUSH; 2725 hdr->sadb_msg_type = SADB_X_SPDFLUSH;
2738 hdr->sadb_msg_seq = c->seq; 2726 hdr->sadb_msg_seq = c->seq;
2739 hdr->sadb_msg_pid = c->portid; 2727 hdr->sadb_msg_pid = c->portid;
@@ -2917,7 +2905,7 @@ static void dump_ah_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)
2917 struct sadb_prop *p; 2905 struct sadb_prop *p;
2918 int i; 2906 int i;
2919 2907
2920 p = (struct sadb_prop*)skb_put(skb, sizeof(struct sadb_prop)); 2908 p = skb_put(skb, sizeof(struct sadb_prop));
2921 p->sadb_prop_len = sizeof(struct sadb_prop)/8; 2909 p->sadb_prop_len = sizeof(struct sadb_prop)/8;
2922 p->sadb_prop_exttype = SADB_EXT_PROPOSAL; 2910 p->sadb_prop_exttype = SADB_EXT_PROPOSAL;
2923 p->sadb_prop_replay = 32; 2911 p->sadb_prop_replay = 32;
@@ -2951,7 +2939,7 @@ static void dump_esp_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)
2951 struct sadb_prop *p; 2939 struct sadb_prop *p;
2952 int i, k; 2940 int i, k;
2953 2941
2954 p = (struct sadb_prop*)skb_put(skb, sizeof(struct sadb_prop)); 2942 p = skb_put(skb, sizeof(struct sadb_prop));
2955 p->sadb_prop_len = sizeof(struct sadb_prop)/8; 2943 p->sadb_prop_len = sizeof(struct sadb_prop)/8;
2956 p->sadb_prop_exttype = SADB_EXT_PROPOSAL; 2944 p->sadb_prop_exttype = SADB_EXT_PROPOSAL;
2957 p->sadb_prop_replay = 32; 2945 p->sadb_prop_replay = 32;
@@ -2977,7 +2965,7 @@ static void dump_esp_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)
2977 continue; 2965 continue;
2978 if (!(aalg_tmpl_set(t, aalg) && aalg->available)) 2966 if (!(aalg_tmpl_set(t, aalg) && aalg->available))
2979 continue; 2967 continue;
2980 c = (struct sadb_comb*)skb_put(skb, sizeof(struct sadb_comb)); 2968 c = skb_put(skb, sizeof(struct sadb_comb));
2981 memset(c, 0, sizeof(*c)); 2969 memset(c, 0, sizeof(*c));
2982 p->sadb_prop_len += sizeof(struct sadb_comb)/8; 2970 p->sadb_prop_len += sizeof(struct sadb_comb)/8;
2983 c->sadb_comb_auth = aalg->desc.sadb_alg_id; 2971 c->sadb_comb_auth = aalg->desc.sadb_alg_id;
@@ -3144,7 +3132,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
3144 if (skb == NULL) 3132 if (skb == NULL)
3145 return -ENOMEM; 3133 return -ENOMEM;
3146 3134
3147 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); 3135 hdr = skb_put(skb, sizeof(struct sadb_msg));
3148 hdr->sadb_msg_version = PF_KEY_V2; 3136 hdr->sadb_msg_version = PF_KEY_V2;
3149 hdr->sadb_msg_type = SADB_ACQUIRE; 3137 hdr->sadb_msg_type = SADB_ACQUIRE;
3150 hdr->sadb_msg_satype = pfkey_proto2satype(x->id.proto); 3138 hdr->sadb_msg_satype = pfkey_proto2satype(x->id.proto);
@@ -3155,8 +3143,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
3155 hdr->sadb_msg_pid = 0; 3143 hdr->sadb_msg_pid = 0;
3156 3144
3157 /* src address */ 3145 /* src address */
3158 addr = (struct sadb_address*) skb_put(skb, 3146 addr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);
3159 sizeof(struct sadb_address)+sockaddr_size);
3160 addr->sadb_address_len = 3147 addr->sadb_address_len =
3161 (sizeof(struct sadb_address)+sockaddr_size)/ 3148 (sizeof(struct sadb_address)+sockaddr_size)/
3162 sizeof(uint64_t); 3149 sizeof(uint64_t);
@@ -3171,8 +3158,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
3171 BUG(); 3158 BUG();
3172 3159
3173 /* dst address */ 3160 /* dst address */
3174 addr = (struct sadb_address*) skb_put(skb, 3161 addr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);
3175 sizeof(struct sadb_address)+sockaddr_size);
3176 addr->sadb_address_len = 3162 addr->sadb_address_len =
3177 (sizeof(struct sadb_address)+sockaddr_size)/ 3163 (sizeof(struct sadb_address)+sockaddr_size)/
3178 sizeof(uint64_t); 3164 sizeof(uint64_t);
@@ -3186,7 +3172,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
3186 if (!addr->sadb_address_prefixlen) 3172 if (!addr->sadb_address_prefixlen)
3187 BUG(); 3173 BUG();
3188 3174
3189 pol = (struct sadb_x_policy *) skb_put(skb, sizeof(struct sadb_x_policy)); 3175 pol = skb_put(skb, sizeof(struct sadb_x_policy));
3190 pol->sadb_x_policy_len = sizeof(struct sadb_x_policy)/sizeof(uint64_t); 3176 pol->sadb_x_policy_len = sizeof(struct sadb_x_policy)/sizeof(uint64_t);
3191 pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY; 3177 pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
3192 pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC; 3178 pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;
@@ -3203,8 +3189,8 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
3203 3189
3204 /* security context */ 3190 /* security context */
3205 if (xfrm_ctx) { 3191 if (xfrm_ctx) {
3206 sec_ctx = (struct sadb_x_sec_ctx *) skb_put(skb, 3192 sec_ctx = skb_put(skb,
3207 sizeof(struct sadb_x_sec_ctx) + ctx_size); 3193 sizeof(struct sadb_x_sec_ctx) + ctx_size);
3208 sec_ctx->sadb_x_sec_len = 3194 sec_ctx->sadb_x_sec_len =
3209 (sizeof(struct sadb_x_sec_ctx) + ctx_size) / sizeof(uint64_t); 3195 (sizeof(struct sadb_x_sec_ctx) + ctx_size) / sizeof(uint64_t);
3210 sec_ctx->sadb_x_sec_exttype = SADB_X_EXT_SEC_CTX; 3196 sec_ctx->sadb_x_sec_exttype = SADB_X_EXT_SEC_CTX;
@@ -3346,7 +3332,7 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
3346 if (skb == NULL) 3332 if (skb == NULL)
3347 return -ENOMEM; 3333 return -ENOMEM;
3348 3334
3349 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); 3335 hdr = skb_put(skb, sizeof(struct sadb_msg));
3350 hdr->sadb_msg_version = PF_KEY_V2; 3336 hdr->sadb_msg_version = PF_KEY_V2;
3351 hdr->sadb_msg_type = SADB_X_NAT_T_NEW_MAPPING; 3337 hdr->sadb_msg_type = SADB_X_NAT_T_NEW_MAPPING;
3352 hdr->sadb_msg_satype = satype; 3338 hdr->sadb_msg_satype = satype;
@@ -3357,7 +3343,7 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
3357 hdr->sadb_msg_pid = 0; 3343 hdr->sadb_msg_pid = 0;
3358 3344
3359 /* SA */ 3345 /* SA */
3360 sa = (struct sadb_sa *) skb_put(skb, sizeof(struct sadb_sa)); 3346 sa = skb_put(skb, sizeof(struct sadb_sa));
3361 sa->sadb_sa_len = sizeof(struct sadb_sa)/sizeof(uint64_t); 3347 sa->sadb_sa_len = sizeof(struct sadb_sa)/sizeof(uint64_t);
3362 sa->sadb_sa_exttype = SADB_EXT_SA; 3348 sa->sadb_sa_exttype = SADB_EXT_SA;
3363 sa->sadb_sa_spi = x->id.spi; 3349 sa->sadb_sa_spi = x->id.spi;
@@ -3368,8 +3354,7 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
3368 sa->sadb_sa_flags = 0; 3354 sa->sadb_sa_flags = 0;
3369 3355
3370 /* ADDRESS_SRC (old addr) */ 3356 /* ADDRESS_SRC (old addr) */
3371 addr = (struct sadb_address*) 3357 addr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);
3372 skb_put(skb, sizeof(struct sadb_address)+sockaddr_size);
3373 addr->sadb_address_len = 3358 addr->sadb_address_len =
3374 (sizeof(struct sadb_address)+sockaddr_size)/ 3359 (sizeof(struct sadb_address)+sockaddr_size)/
3375 sizeof(uint64_t); 3360 sizeof(uint64_t);
@@ -3384,15 +3369,14 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
3384 BUG(); 3369 BUG();
3385 3370
3386 /* NAT_T_SPORT (old port) */ 3371 /* NAT_T_SPORT (old port) */
3387 n_port = (struct sadb_x_nat_t_port*) skb_put(skb, sizeof (*n_port)); 3372 n_port = skb_put(skb, sizeof(*n_port));
3388 n_port->sadb_x_nat_t_port_len = sizeof(*n_port)/sizeof(uint64_t); 3373 n_port->sadb_x_nat_t_port_len = sizeof(*n_port)/sizeof(uint64_t);
3389 n_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_SPORT; 3374 n_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_SPORT;
3390 n_port->sadb_x_nat_t_port_port = natt->encap_sport; 3375 n_port->sadb_x_nat_t_port_port = natt->encap_sport;
3391 n_port->sadb_x_nat_t_port_reserved = 0; 3376 n_port->sadb_x_nat_t_port_reserved = 0;
3392 3377
3393 /* ADDRESS_DST (new addr) */ 3378 /* ADDRESS_DST (new addr) */
3394 addr = (struct sadb_address*) 3379 addr = skb_put(skb, sizeof(struct sadb_address) + sockaddr_size);
3395 skb_put(skb, sizeof(struct sadb_address)+sockaddr_size);
3396 addr->sadb_address_len = 3380 addr->sadb_address_len =
3397 (sizeof(struct sadb_address)+sockaddr_size)/ 3381 (sizeof(struct sadb_address)+sockaddr_size)/
3398 sizeof(uint64_t); 3382 sizeof(uint64_t);
@@ -3407,7 +3391,7 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
3407 BUG(); 3391 BUG();
3408 3392
3409 /* NAT_T_DPORT (new port) */ 3393 /* NAT_T_DPORT (new port) */
3410 n_port = (struct sadb_x_nat_t_port*) skb_put(skb, sizeof (*n_port)); 3394 n_port = skb_put(skb, sizeof(*n_port));
3411 n_port->sadb_x_nat_t_port_len = sizeof(*n_port)/sizeof(uint64_t); 3395 n_port->sadb_x_nat_t_port_len = sizeof(*n_port)/sizeof(uint64_t);
3412 n_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_DPORT; 3396 n_port->sadb_x_nat_t_port_exttype = SADB_X_EXT_NAT_T_DPORT;
3413 n_port->sadb_x_nat_t_port_port = sport; 3397 n_port->sadb_x_nat_t_port_port = sport;
@@ -3421,7 +3405,7 @@ static int set_sadb_address(struct sk_buff *skb, int sasize, int type,
3421 const struct xfrm_selector *sel) 3405 const struct xfrm_selector *sel)
3422{ 3406{
3423 struct sadb_address *addr; 3407 struct sadb_address *addr;
3424 addr = (struct sadb_address *)skb_put(skb, sizeof(struct sadb_address) + sasize); 3408 addr = skb_put(skb, sizeof(struct sadb_address) + sasize);
3425 addr->sadb_address_len = (sizeof(struct sadb_address) + sasize)/8; 3409 addr->sadb_address_len = (sizeof(struct sadb_address) + sasize)/8;
3426 addr->sadb_address_exttype = type; 3410 addr->sadb_address_exttype = type;
3427 addr->sadb_address_proto = sel->proto; 3411 addr->sadb_address_proto = sel->proto;
@@ -3553,7 +3537,7 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
3553 if (skb == NULL) 3537 if (skb == NULL)
3554 return -ENOMEM; 3538 return -ENOMEM;
3555 3539
3556 hdr = (struct sadb_msg *)skb_put(skb, sizeof(struct sadb_msg)); 3540 hdr = skb_put(skb, sizeof(struct sadb_msg));
3557 hdr->sadb_msg_version = PF_KEY_V2; 3541 hdr->sadb_msg_version = PF_KEY_V2;
3558 hdr->sadb_msg_type = SADB_X_MIGRATE; 3542 hdr->sadb_msg_type = SADB_X_MIGRATE;
3559 hdr->sadb_msg_satype = pfkey_proto2satype(m->proto); 3543 hdr->sadb_msg_satype = pfkey_proto2satype(m->proto);
@@ -3574,7 +3558,7 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
3574 set_sadb_address(skb, sasize_sel, SADB_EXT_ADDRESS_DST, sel); 3558 set_sadb_address(skb, sasize_sel, SADB_EXT_ADDRESS_DST, sel);
3575 3559
3576 /* policy information */ 3560 /* policy information */
3577 pol = (struct sadb_x_policy *)skb_put(skb, sizeof(struct sadb_x_policy)); 3561 pol = skb_put(skb, sizeof(struct sadb_x_policy));
3578 pol->sadb_x_policy_len = size_pol / 8; 3562 pol->sadb_x_policy_len = size_pol / 8;
3579 pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY; 3563 pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
3580 pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC; 3564 pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;