aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r--net/xfrm/xfrm_user.c179
1 files changed, 107 insertions, 72 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 816e3690b60f..69110fed64b6 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -71,7 +71,7 @@ static int verify_one_alg(struct rtattr **xfrma, enum xfrm_attr_type_t type)
71 71
72 default: 72 default:
73 return -EINVAL; 73 return -EINVAL;
74 }; 74 }
75 75
76 algp->alg_name[CRYPTO_MAX_ALG_NAME - 1] = '\0'; 76 algp->alg_name[CRYPTO_MAX_ALG_NAME - 1] = '\0';
77 return 0; 77 return 0;
@@ -152,7 +152,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
152 152
153 default: 153 default:
154 goto out; 154 goto out;
155 }; 155 }
156 156
157 err = -EINVAL; 157 err = -EINVAL;
158 switch (p->id.proto) { 158 switch (p->id.proto) {
@@ -192,7 +192,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
192 192
193 default: 193 default:
194 goto out; 194 goto out;
195 }; 195 }
196 196
197 if ((err = verify_one_alg(xfrma, XFRMA_ALG_AUTH))) 197 if ((err = verify_one_alg(xfrma, XFRMA_ALG_AUTH)))
198 goto out; 198 goto out;
@@ -217,7 +217,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
217 217
218 default: 218 default:
219 goto out; 219 goto out;
220 }; 220 }
221 221
222 err = 0; 222 err = 0;
223 223
@@ -576,7 +576,7 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr)
576 struct sk_buff *skb = sp->out_skb; 576 struct sk_buff *skb = sp->out_skb;
577 struct xfrm_usersa_info *p; 577 struct xfrm_usersa_info *p;
578 struct nlmsghdr *nlh; 578 struct nlmsghdr *nlh;
579 unsigned char *b = skb->tail; 579 unsigned char *b = skb_tail_pointer(skb);
580 580
581 if (sp->this_idx < sp->start_idx) 581 if (sp->this_idx < sp->start_idx)
582 goto out; 582 goto out;
@@ -621,14 +621,14 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr)
621 if (x->lastused) 621 if (x->lastused)
622 RTA_PUT(skb, XFRMA_LASTUSED, sizeof(x->lastused), &x->lastused); 622 RTA_PUT(skb, XFRMA_LASTUSED, sizeof(x->lastused), &x->lastused);
623 623
624 nlh->nlmsg_len = skb->tail - b; 624 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
625out: 625out:
626 sp->this_idx++; 626 sp->this_idx++;
627 return 0; 627 return 0;
628 628
629nlmsg_failure: 629nlmsg_failure:
630rtattr_failure: 630rtattr_failure:
631 skb_trim(skb, b - skb->data); 631 nlmsg_trim(skb, b);
632 return -1; 632 return -1;
633} 633}
634 634
@@ -672,6 +672,61 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,
672 return skb; 672 return skb;
673} 673}
674 674
675static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
676{
677 struct xfrm_sadinfo si;
678 struct nlmsghdr *nlh;
679 u32 *f;
680
681 nlh = nlmsg_put(skb, pid, seq, XFRM_MSG_NEWSADINFO, sizeof(u32), 0);
682 if (nlh == NULL) /* shouldnt really happen ... */
683 return -EMSGSIZE;
684
685 f = nlmsg_data(nlh);
686 *f = flags;
687 xfrm_sad_getinfo(&si);
688
689 if (flags & XFRM_SAD_HMASK)
690 NLA_PUT_U32(skb, XFRMA_SADHMASK, si.sadhcnt);
691 if (flags & XFRM_SAD_HMAX)
692 NLA_PUT_U32(skb, XFRMA_SADHMAX, si.sadhmcnt);
693 if (flags & XFRM_SAD_CNT)
694 NLA_PUT_U32(skb, XFRMA_SADCNT, si.sadcnt);
695
696 return nlmsg_end(skb, nlh);
697
698nla_put_failure:
699 nlmsg_cancel(skb, nlh);
700 return -EMSGSIZE;
701}
702
703static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
704 struct rtattr **xfrma)
705{
706 struct sk_buff *r_skb;
707 u32 *flags = NLMSG_DATA(nlh);
708 u32 spid = NETLINK_CB(skb).pid;
709 u32 seq = nlh->nlmsg_seq;
710 int len = NLMSG_LENGTH(sizeof(u32));
711
712 if (*flags & XFRM_SAD_HMASK)
713 len += RTA_SPACE(sizeof(u32));
714 if (*flags & XFRM_SAD_HMAX)
715 len += RTA_SPACE(sizeof(u32));
716 if (*flags & XFRM_SAD_CNT)
717 len += RTA_SPACE(sizeof(u32));
718
719 r_skb = alloc_skb(len, GFP_ATOMIC);
720
721 if (r_skb == NULL)
722 return -ENOMEM;
723
724 if (build_sadinfo(r_skb, spid, seq, *flags) < 0)
725 BUG();
726
727 return nlmsg_unicast(xfrm_nl, r_skb, spid);
728}
729
675static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh, 730static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
676 struct rtattr **xfrma) 731 struct rtattr **xfrma)
677{ 732{
@@ -711,7 +766,7 @@ static int verify_userspi_info(struct xfrm_userspi_info *p)
711 766
712 default: 767 default:
713 return -EINVAL; 768 return -EINVAL;
714 }; 769 }
715 770
716 if (p->min > p->max) 771 if (p->min > p->max)
717 return -EINVAL; 772 return -EINVAL;
@@ -789,7 +844,7 @@ static int verify_policy_dir(u8 dir)
789 844
790 default: 845 default:
791 return -EINVAL; 846 return -EINVAL;
792 }; 847 }
793 848
794 return 0; 849 return 0;
795} 850}
@@ -805,7 +860,7 @@ static int verify_policy_type(u8 type)
805 860
806 default: 861 default:
807 return -EINVAL; 862 return -EINVAL;
808 }; 863 }
809 864
810 return 0; 865 return 0;
811} 866}
@@ -821,7 +876,7 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p)
821 876
822 default: 877 default:
823 return -EINVAL; 878 return -EINVAL;
824 }; 879 }
825 880
826 switch (p->action) { 881 switch (p->action) {
827 case XFRM_POLICY_ALLOW: 882 case XFRM_POLICY_ALLOW:
@@ -830,7 +885,7 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p)
830 885
831 default: 886 default:
832 return -EINVAL; 887 return -EINVAL;
833 }; 888 }
834 889
835 switch (p->sel.family) { 890 switch (p->sel.family) {
836 case AF_INET: 891 case AF_INET:
@@ -845,7 +900,7 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p)
845 900
846 default: 901 default:
847 return -EINVAL; 902 return -EINVAL;
848 }; 903 }
849 904
850 return verify_policy_dir(p->dir); 905 return verify_policy_dir(p->dir);
851} 906}
@@ -912,7 +967,7 @@ static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family)
912#endif 967#endif
913 default: 968 default:
914 return -EINVAL; 969 return -EINVAL;
915 }; 970 }
916 } 971 }
917 972
918 return 0; 973 return 0;
@@ -1157,7 +1212,7 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
1157 struct sk_buff *in_skb = sp->in_skb; 1212 struct sk_buff *in_skb = sp->in_skb;
1158 struct sk_buff *skb = sp->out_skb; 1213 struct sk_buff *skb = sp->out_skb;
1159 struct nlmsghdr *nlh; 1214 struct nlmsghdr *nlh;
1160 unsigned char *b = skb->tail; 1215 unsigned char *b = skb_tail_pointer(skb);
1161 1216
1162 if (sp->this_idx < sp->start_idx) 1217 if (sp->this_idx < sp->start_idx)
1163 goto out; 1218 goto out;
@@ -1176,13 +1231,13 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
1176 if (copy_to_user_policy_type(xp->type, skb) < 0) 1231 if (copy_to_user_policy_type(xp->type, skb) < 0)
1177 goto nlmsg_failure; 1232 goto nlmsg_failure;
1178 1233
1179 nlh->nlmsg_len = skb->tail - b; 1234 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1180out: 1235out:
1181 sp->this_idx++; 1236 sp->this_idx++;
1182 return 0; 1237 return 0;
1183 1238
1184nlmsg_failure: 1239nlmsg_failure:
1185 skb_trim(skb, b - skb->data); 1240 nlmsg_trim(skb, b);
1186 return -1; 1241 return -1;
1187} 1242}
1188 1243
@@ -1330,7 +1385,7 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, struct km_eve
1330 struct xfrm_aevent_id *id; 1385 struct xfrm_aevent_id *id;
1331 struct nlmsghdr *nlh; 1386 struct nlmsghdr *nlh;
1332 struct xfrm_lifetime_cur ltime; 1387 struct xfrm_lifetime_cur ltime;
1333 unsigned char *b = skb->tail; 1388 unsigned char *b = skb_tail_pointer(skb);
1334 1389
1335 nlh = NLMSG_PUT(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id)); 1390 nlh = NLMSG_PUT(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id));
1336 id = NLMSG_DATA(nlh); 1391 id = NLMSG_DATA(nlh);
@@ -1362,12 +1417,12 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, struct km_eve
1362 RTA_PUT(skb,XFRMA_ETIMER_THRESH,sizeof(u32),&etimer); 1417 RTA_PUT(skb,XFRMA_ETIMER_THRESH,sizeof(u32),&etimer);
1363 } 1418 }
1364 1419
1365 nlh->nlmsg_len = skb->tail - b; 1420 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1366 return skb->len; 1421 return skb->len;
1367 1422
1368rtattr_failure: 1423rtattr_failure:
1369nlmsg_failure: 1424nlmsg_failure:
1370 skb_trim(skb, b - skb->data); 1425 nlmsg_trim(skb, b);
1371 return -1; 1426 return -1;
1372} 1427}
1373 1428
@@ -1744,7 +1799,7 @@ static int build_migrate(struct sk_buff *skb, struct xfrm_migrate *m,
1744 struct xfrm_migrate *mp; 1799 struct xfrm_migrate *mp;
1745 struct xfrm_userpolicy_id *pol_id; 1800 struct xfrm_userpolicy_id *pol_id;
1746 struct nlmsghdr *nlh; 1801 struct nlmsghdr *nlh;
1747 unsigned char *b = skb->tail; 1802 unsigned char *b = skb_tail_pointer(skb);
1748 int i; 1803 int i;
1749 1804
1750 nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id)); 1805 nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id));
@@ -1764,10 +1819,10 @@ static int build_migrate(struct sk_buff *skb, struct xfrm_migrate *m,
1764 goto nlmsg_failure; 1819 goto nlmsg_failure;
1765 } 1820 }
1766 1821
1767 nlh->nlmsg_len = skb->tail - b; 1822 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1768 return skb->len; 1823 return skb->len;
1769nlmsg_failure: 1824nlmsg_failure:
1770 skb_trim(skb, b - skb->data); 1825 nlmsg_trim(skb, b);
1771 return -1; 1826 return -1;
1772} 1827}
1773 1828
@@ -1823,6 +1878,7 @@ static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
1823 [XFRM_MSG_GETAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id), 1878 [XFRM_MSG_GETAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id),
1824 [XFRM_MSG_REPORT - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_report), 1879 [XFRM_MSG_REPORT - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_report),
1825 [XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id), 1880 [XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
1881 [XFRM_MSG_GETSADINFO - XFRM_MSG_BASE] = NLMSG_LENGTH(sizeof(u32)),
1826}; 1882};
1827 1883
1828#undef XMSGSIZE 1884#undef XMSGSIZE
@@ -1850,55 +1906,39 @@ static struct xfrm_link {
1850 [XFRM_MSG_NEWAE - XFRM_MSG_BASE] = { .doit = xfrm_new_ae }, 1906 [XFRM_MSG_NEWAE - XFRM_MSG_BASE] = { .doit = xfrm_new_ae },
1851 [XFRM_MSG_GETAE - XFRM_MSG_BASE] = { .doit = xfrm_get_ae }, 1907 [XFRM_MSG_GETAE - XFRM_MSG_BASE] = { .doit = xfrm_get_ae },
1852 [XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = { .doit = xfrm_do_migrate }, 1908 [XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = { .doit = xfrm_do_migrate },
1909 [XFRM_MSG_GETSADINFO - XFRM_MSG_BASE] = { .doit = xfrm_get_sadinfo },
1853}; 1910};
1854 1911
1855static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp) 1912static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1856{ 1913{
1857 struct rtattr *xfrma[XFRMA_MAX]; 1914 struct rtattr *xfrma[XFRMA_MAX];
1858 struct xfrm_link *link; 1915 struct xfrm_link *link;
1859 int type, min_len; 1916 int type, min_len;
1860 1917
1861 if (!(nlh->nlmsg_flags & NLM_F_REQUEST))
1862 return 0;
1863
1864 type = nlh->nlmsg_type; 1918 type = nlh->nlmsg_type;
1865
1866 /* A control message: ignore them */
1867 if (type < XFRM_MSG_BASE)
1868 return 0;
1869
1870 /* Unknown message: reply with EINVAL */
1871 if (type > XFRM_MSG_MAX) 1919 if (type > XFRM_MSG_MAX)
1872 goto err_einval; 1920 return -EINVAL;
1873 1921
1874 type -= XFRM_MSG_BASE; 1922 type -= XFRM_MSG_BASE;
1875 link = &xfrm_dispatch[type]; 1923 link = &xfrm_dispatch[type];
1876 1924
1877 /* All operations require privileges, even GET */ 1925 /* All operations require privileges, even GET */
1878 if (security_netlink_recv(skb, CAP_NET_ADMIN)) { 1926 if (security_netlink_recv(skb, CAP_NET_ADMIN))
1879 *errp = -EPERM; 1927 return -EPERM;
1880 return -1;
1881 }
1882 1928
1883 if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) || 1929 if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) ||
1884 type == (XFRM_MSG_GETPOLICY - XFRM_MSG_BASE)) && 1930 type == (XFRM_MSG_GETPOLICY - XFRM_MSG_BASE)) &&
1885 (nlh->nlmsg_flags & NLM_F_DUMP)) { 1931 (nlh->nlmsg_flags & NLM_F_DUMP)) {
1886 if (link->dump == NULL) 1932 if (link->dump == NULL)
1887 goto err_einval; 1933 return -EINVAL;
1888
1889 if ((*errp = netlink_dump_start(xfrm_nl, skb, nlh,
1890 link->dump, NULL)) != 0) {
1891 return -1;
1892 }
1893 1934
1894 netlink_queue_skip(nlh, skb); 1935 return netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL);
1895 return -1;
1896 } 1936 }
1897 1937
1898 memset(xfrma, 0, sizeof(xfrma)); 1938 memset(xfrma, 0, sizeof(xfrma));
1899 1939
1900 if (nlh->nlmsg_len < (min_len = xfrm_msg_min[type])) 1940 if (nlh->nlmsg_len < (min_len = xfrm_msg_min[type]))
1901 goto err_einval; 1941 return -EINVAL;
1902 1942
1903 if (nlh->nlmsg_len > min_len) { 1943 if (nlh->nlmsg_len > min_len) {
1904 int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len); 1944 int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
@@ -1908,7 +1948,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *err
1908 unsigned short flavor = attr->rta_type; 1948 unsigned short flavor = attr->rta_type;
1909 if (flavor) { 1949 if (flavor) {
1910 if (flavor > XFRMA_MAX) 1950 if (flavor > XFRMA_MAX)
1911 goto err_einval; 1951 return -EINVAL;
1912 xfrma[flavor - 1] = attr; 1952 xfrma[flavor - 1] = attr;
1913 } 1953 }
1914 attr = RTA_NEXT(attr, attrlen); 1954 attr = RTA_NEXT(attr, attrlen);
@@ -1916,14 +1956,9 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *err
1916 } 1956 }
1917 1957
1918 if (link->doit == NULL) 1958 if (link->doit == NULL)
1919 goto err_einval; 1959 return -EINVAL;
1920 *errp = link->doit(skb, nlh, xfrma);
1921
1922 return *errp;
1923 1960
1924err_einval: 1961 return link->doit(skb, nlh, xfrma);
1925 *errp = -EINVAL;
1926 return -1;
1927} 1962}
1928 1963
1929static void xfrm_netlink_rcv(struct sock *sk, int len) 1964static void xfrm_netlink_rcv(struct sock *sk, int len)
@@ -1942,7 +1977,7 @@ static int build_expire(struct sk_buff *skb, struct xfrm_state *x, struct km_eve
1942{ 1977{
1943 struct xfrm_user_expire *ue; 1978 struct xfrm_user_expire *ue;
1944 struct nlmsghdr *nlh; 1979 struct nlmsghdr *nlh;
1945 unsigned char *b = skb->tail; 1980 unsigned char *b = skb_tail_pointer(skb);
1946 1981
1947 nlh = NLMSG_PUT(skb, c->pid, 0, XFRM_MSG_EXPIRE, 1982 nlh = NLMSG_PUT(skb, c->pid, 0, XFRM_MSG_EXPIRE,
1948 sizeof(*ue)); 1983 sizeof(*ue));
@@ -1952,11 +1987,11 @@ static int build_expire(struct sk_buff *skb, struct xfrm_state *x, struct km_eve
1952 copy_to_user_state(x, &ue->state); 1987 copy_to_user_state(x, &ue->state);
1953 ue->hard = (c->data.hard != 0) ? 1 : 0; 1988 ue->hard = (c->data.hard != 0) ? 1 : 0;
1954 1989
1955 nlh->nlmsg_len = skb->tail - b; 1990 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1956 return skb->len; 1991 return skb->len;
1957 1992
1958nlmsg_failure: 1993nlmsg_failure:
1959 skb_trim(skb, b - skb->data); 1994 nlmsg_trim(skb, b);
1960 return -1; 1995 return -1;
1961} 1996}
1962 1997
@@ -1999,7 +2034,7 @@ static int xfrm_notify_sa_flush(struct km_event *c)
1999 struct xfrm_usersa_flush *p; 2034 struct xfrm_usersa_flush *p;
2000 struct nlmsghdr *nlh; 2035 struct nlmsghdr *nlh;
2001 struct sk_buff *skb; 2036 struct sk_buff *skb;
2002 unsigned char *b; 2037 sk_buff_data_t b;
2003 int len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_flush)); 2038 int len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_flush));
2004 2039
2005 skb = alloc_skb(len, GFP_ATOMIC); 2040 skb = alloc_skb(len, GFP_ATOMIC);
@@ -2045,7 +2080,7 @@ static int xfrm_notify_sa(struct xfrm_state *x, struct km_event *c)
2045 struct xfrm_usersa_id *id; 2080 struct xfrm_usersa_id *id;
2046 struct nlmsghdr *nlh; 2081 struct nlmsghdr *nlh;
2047 struct sk_buff *skb; 2082 struct sk_buff *skb;
2048 unsigned char *b; 2083 sk_buff_data_t b;
2049 int len = xfrm_sa_len(x); 2084 int len = xfrm_sa_len(x);
2050 int headlen; 2085 int headlen;
2051 2086
@@ -2129,7 +2164,7 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x,
2129{ 2164{
2130 struct xfrm_user_acquire *ua; 2165 struct xfrm_user_acquire *ua;
2131 struct nlmsghdr *nlh; 2166 struct nlmsghdr *nlh;
2132 unsigned char *b = skb->tail; 2167 unsigned char *b = skb_tail_pointer(skb);
2133 __u32 seq = xfrm_get_acqseq(); 2168 __u32 seq = xfrm_get_acqseq();
2134 2169
2135 nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_ACQUIRE, 2170 nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_ACQUIRE,
@@ -2153,11 +2188,11 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x,
2153 if (copy_to_user_policy_type(xp->type, skb) < 0) 2188 if (copy_to_user_policy_type(xp->type, skb) < 0)
2154 goto nlmsg_failure; 2189 goto nlmsg_failure;
2155 2190
2156 nlh->nlmsg_len = skb->tail - b; 2191 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
2157 return skb->len; 2192 return skb->len;
2158 2193
2159nlmsg_failure: 2194nlmsg_failure:
2160 skb_trim(skb, b - skb->data); 2195 nlmsg_trim(skb, b);
2161 return -1; 2196 return -1;
2162} 2197}
2163 2198
@@ -2249,7 +2284,7 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp,
2249 struct xfrm_user_polexpire *upe; 2284 struct xfrm_user_polexpire *upe;
2250 struct nlmsghdr *nlh; 2285 struct nlmsghdr *nlh;
2251 int hard = c->data.hard; 2286 int hard = c->data.hard;
2252 unsigned char *b = skb->tail; 2287 unsigned char *b = skb_tail_pointer(skb);
2253 2288
2254 nlh = NLMSG_PUT(skb, c->pid, 0, XFRM_MSG_POLEXPIRE, sizeof(*upe)); 2289 nlh = NLMSG_PUT(skb, c->pid, 0, XFRM_MSG_POLEXPIRE, sizeof(*upe));
2255 upe = NLMSG_DATA(nlh); 2290 upe = NLMSG_DATA(nlh);
@@ -2264,11 +2299,11 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp,
2264 goto nlmsg_failure; 2299 goto nlmsg_failure;
2265 upe->hard = !!hard; 2300 upe->hard = !!hard;
2266 2301
2267 nlh->nlmsg_len = skb->tail - b; 2302 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
2268 return skb->len; 2303 return skb->len;
2269 2304
2270nlmsg_failure: 2305nlmsg_failure:
2271 skb_trim(skb, b - skb->data); 2306 nlmsg_trim(skb, b);
2272 return -1; 2307 return -1;
2273} 2308}
2274 2309
@@ -2300,7 +2335,7 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *
2300 struct xfrm_userpolicy_id *id; 2335 struct xfrm_userpolicy_id *id;
2301 struct nlmsghdr *nlh; 2336 struct nlmsghdr *nlh;
2302 struct sk_buff *skb; 2337 struct sk_buff *skb;
2303 unsigned char *b; 2338 sk_buff_data_t b;
2304 int len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); 2339 int len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
2305 int headlen; 2340 int headlen;
2306 2341
@@ -2357,7 +2392,7 @@ static int xfrm_notify_policy_flush(struct km_event *c)
2357{ 2392{
2358 struct nlmsghdr *nlh; 2393 struct nlmsghdr *nlh;
2359 struct sk_buff *skb; 2394 struct sk_buff *skb;
2360 unsigned char *b; 2395 sk_buff_data_t b;
2361 int len = 0; 2396 int len = 0;
2362#ifdef CONFIG_XFRM_SUB_POLICY 2397#ifdef CONFIG_XFRM_SUB_POLICY
2363 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); 2398 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
@@ -2410,7 +2445,7 @@ static int build_report(struct sk_buff *skb, u8 proto,
2410{ 2445{
2411 struct xfrm_user_report *ur; 2446 struct xfrm_user_report *ur;
2412 struct nlmsghdr *nlh; 2447 struct nlmsghdr *nlh;
2413 unsigned char *b = skb->tail; 2448 unsigned char *b = skb_tail_pointer(skb);
2414 2449
2415 nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_REPORT, sizeof(*ur)); 2450 nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_REPORT, sizeof(*ur));
2416 ur = NLMSG_DATA(nlh); 2451 ur = NLMSG_DATA(nlh);
@@ -2422,12 +2457,12 @@ static int build_report(struct sk_buff *skb, u8 proto,
2422 if (addr) 2457 if (addr)
2423 RTA_PUT(skb, XFRMA_COADDR, sizeof(*addr), addr); 2458 RTA_PUT(skb, XFRMA_COADDR, sizeof(*addr), addr);
2424 2459
2425 nlh->nlmsg_len = skb->tail - b; 2460 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
2426 return skb->len; 2461 return skb->len;
2427 2462
2428nlmsg_failure: 2463nlmsg_failure:
2429rtattr_failure: 2464rtattr_failure:
2430 skb_trim(skb, b - skb->data); 2465 nlmsg_trim(skb, b);
2431 return -1; 2466 return -1;
2432} 2467}
2433 2468
@@ -2466,7 +2501,7 @@ static int __init xfrm_user_init(void)
2466 printk(KERN_INFO "Initializing XFRM netlink socket\n"); 2501 printk(KERN_INFO "Initializing XFRM netlink socket\n");
2467 2502
2468 nlsk = netlink_kernel_create(NETLINK_XFRM, XFRMNLGRP_MAX, 2503 nlsk = netlink_kernel_create(NETLINK_XFRM, XFRMNLGRP_MAX,
2469 xfrm_netlink_rcv, THIS_MODULE); 2504 xfrm_netlink_rcv, NULL, THIS_MODULE);
2470 if (nlsk == NULL) 2505 if (nlsk == NULL)
2471 return -ENOMEM; 2506 return -ENOMEM;
2472 rcu_assign_pointer(xfrm_nl, nlsk); 2507 rcu_assign_pointer(xfrm_nl, nlsk);