aboutsummaryrefslogtreecommitdiffstats
path: root/net/key/af_key.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 16:38:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 16:38:27 -0400
commitaecdc33e111b2c447b622e287c6003726daa1426 (patch)
tree3e7657eae4b785e1a1fb5dfb225dbae0b2f0cfc6 /net/key/af_key.c
parenta20acf99f75e49271381d65db097c9763060a1e8 (diff)
parenta3a6cab5ea10cca64d036851fe0d932448f2fe4f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking changes from David Miller: 1) GRE now works over ipv6, from Dmitry Kozlov. 2) Make SCTP more network namespace aware, from Eric Biederman. 3) TEAM driver now works with non-ethernet devices, from Jiri Pirko. 4) Make openvswitch network namespace aware, from Pravin B Shelar. 5) IPV6 NAT implementation, from Patrick McHardy. 6) Server side support for TCP Fast Open, from Jerry Chu and others. 7) Packet BPF filter supports MOD and XOR, from Eric Dumazet and Daniel Borkmann. 8) Increate the loopback default MTU to 64K, from Eric Dumazet. 9) Use a per-task rather than per-socket page fragment allocator for outgoing networking traffic. This benefits processes that have very many mostly idle sockets, which is quite common. From Eric Dumazet. 10) Use up to 32K for page fragment allocations, with fallbacks to smaller sizes when higher order page allocations fail. Benefits are a) less segments for driver to process b) less calls to page allocator c) less waste of space. From Eric Dumazet. 11) Allow GRO to be used on GRE tunnels, from Eric Dumazet. 12) VXLAN device driver, one way to handle VLAN issues such as the limitation of 4096 VLAN IDs yet still have some level of isolation. From Stephen Hemminger. 13) As usual there is a large boatload of driver changes, with the scale perhaps tilted towards the wireless side this time around. Fix up various fairly trivial conflicts, mostly caused by the user namespace changes. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1012 commits) hyperv: Add buffer for extended info after the RNDIS response message. hyperv: Report actual status in receive completion packet hyperv: Remove extra allocated space for recv_pkt_list elements hyperv: Fix page buffer handling in rndis_filter_send_request() hyperv: Fix the missing return value in rndis_filter_set_packet_filter() hyperv: Fix the max_xfer_size in RNDIS initialization vxlan: put UDP socket in correct namespace vxlan: Depend on CONFIG_INET sfc: Fix the reported priorities of different filter types sfc: Remove EFX_FILTER_FLAG_RX_OVERRIDE_IP sfc: Fix loopback self-test with separate_tx_channels=1 sfc: Fix MCDI structure field lookup sfc: Add parentheses around use of bitfield macro arguments sfc: Fix null function pointer in efx_sriov_channel_type vxlan: virtual extensible lan igmp: export symbol ip_mc_leave_group netlink: add attributes to fdb interface tg3: unconditionally select HWMON support when tg3 is enabled. Revert "net: ti cpsw ethernet: allow reading phy interface mode from DT" gre: fix sparse warning ...
Diffstat (limited to 'net/key/af_key.c')
-rw-r--r--net/key/af_key.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 0481d4b51476..08897a3c7ec7 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -54,7 +54,7 @@ struct pfkey_sock {
54 54
55 struct { 55 struct {
56 uint8_t msg_version; 56 uint8_t msg_version;
57 uint32_t msg_pid; 57 uint32_t msg_portid;
58 int (*dump)(struct pfkey_sock *sk); 58 int (*dump)(struct pfkey_sock *sk);
59 void (*done)(struct pfkey_sock *sk); 59 void (*done)(struct pfkey_sock *sk);
60 union { 60 union {
@@ -1447,7 +1447,7 @@ static int key_notify_sa(struct xfrm_state *x, const struct km_event *c)
1447 hdr->sadb_msg_errno = 0; 1447 hdr->sadb_msg_errno = 0;
1448 hdr->sadb_msg_reserved = 0; 1448 hdr->sadb_msg_reserved = 0;
1449 hdr->sadb_msg_seq = c->seq; 1449 hdr->sadb_msg_seq = c->seq;
1450 hdr->sadb_msg_pid = c->pid; 1450 hdr->sadb_msg_pid = c->portid;
1451 1451
1452 pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xs_net(x)); 1452 pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xs_net(x));
1453 1453
@@ -1486,7 +1486,7 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, const struct sadb_msg
1486 else 1486 else
1487 c.event = XFRM_MSG_UPDSA; 1487 c.event = XFRM_MSG_UPDSA;
1488 c.seq = hdr->sadb_msg_seq; 1488 c.seq = hdr->sadb_msg_seq;
1489 c.pid = hdr->sadb_msg_pid; 1489 c.portid = hdr->sadb_msg_pid;
1490 km_state_notify(x, &c); 1490 km_state_notify(x, &c);
1491out: 1491out:
1492 xfrm_state_put(x); 1492 xfrm_state_put(x);
@@ -1523,7 +1523,7 @@ static int pfkey_delete(struct sock *sk, struct sk_buff *skb, const struct sadb_
1523 goto out; 1523 goto out;
1524 1524
1525 c.seq = hdr->sadb_msg_seq; 1525 c.seq = hdr->sadb_msg_seq;
1526 c.pid = hdr->sadb_msg_pid; 1526 c.portid = hdr->sadb_msg_pid;
1527 c.event = XFRM_MSG_DELSA; 1527 c.event = XFRM_MSG_DELSA;
1528 km_state_notify(x, &c); 1528 km_state_notify(x, &c);
1529out: 1529out:
@@ -1701,7 +1701,7 @@ static int key_notify_sa_flush(const struct km_event *c)
1701 hdr->sadb_msg_satype = pfkey_proto2satype(c->data.proto); 1701 hdr->sadb_msg_satype = pfkey_proto2satype(c->data.proto);
1702 hdr->sadb_msg_type = SADB_FLUSH; 1702 hdr->sadb_msg_type = SADB_FLUSH;
1703 hdr->sadb_msg_seq = c->seq; 1703 hdr->sadb_msg_seq = c->seq;
1704 hdr->sadb_msg_pid = c->pid; 1704 hdr->sadb_msg_pid = c->portid;
1705 hdr->sadb_msg_version = PF_KEY_V2; 1705 hdr->sadb_msg_version = PF_KEY_V2;
1706 hdr->sadb_msg_errno = (uint8_t) 0; 1706 hdr->sadb_msg_errno = (uint8_t) 0;
1707 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); 1707 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
@@ -1736,7 +1736,7 @@ static int pfkey_flush(struct sock *sk, struct sk_buff *skb, const struct sadb_m
1736 1736
1737 c.data.proto = proto; 1737 c.data.proto = proto;
1738 c.seq = hdr->sadb_msg_seq; 1738 c.seq = hdr->sadb_msg_seq;
1739 c.pid = hdr->sadb_msg_pid; 1739 c.portid = hdr->sadb_msg_pid;
1740 c.event = XFRM_MSG_FLUSHSA; 1740 c.event = XFRM_MSG_FLUSHSA;
1741 c.net = net; 1741 c.net = net;
1742 km_state_notify(NULL, &c); 1742 km_state_notify(NULL, &c);
@@ -1764,7 +1764,7 @@ static int dump_sa(struct xfrm_state *x, int count, void *ptr)
1764 out_hdr->sadb_msg_errno = 0; 1764 out_hdr->sadb_msg_errno = 0;
1765 out_hdr->sadb_msg_reserved = 0; 1765 out_hdr->sadb_msg_reserved = 0;
1766 out_hdr->sadb_msg_seq = count + 1; 1766 out_hdr->sadb_msg_seq = count + 1;
1767 out_hdr->sadb_msg_pid = pfk->dump.msg_pid; 1767 out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
1768 1768
1769 if (pfk->dump.skb) 1769 if (pfk->dump.skb)
1770 pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE, 1770 pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
@@ -1798,7 +1798,7 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms
1798 return -EINVAL; 1798 return -EINVAL;
1799 1799
1800 pfk->dump.msg_version = hdr->sadb_msg_version; 1800 pfk->dump.msg_version = hdr->sadb_msg_version;
1801 pfk->dump.msg_pid = hdr->sadb_msg_pid; 1801 pfk->dump.msg_portid = hdr->sadb_msg_pid;
1802 pfk->dump.dump = pfkey_dump_sa; 1802 pfk->dump.dump = pfkey_dump_sa;
1803 pfk->dump.done = pfkey_dump_sa_done; 1803 pfk->dump.done = pfkey_dump_sa_done;
1804 xfrm_state_walk_init(&pfk->dump.u.state, proto); 1804 xfrm_state_walk_init(&pfk->dump.u.state, proto);
@@ -1923,6 +1923,9 @@ parse_ipsecrequests(struct xfrm_policy *xp, struct sadb_x_policy *pol)
1923 int len = pol->sadb_x_policy_len*8 - sizeof(struct sadb_x_policy); 1923 int len = pol->sadb_x_policy_len*8 - sizeof(struct sadb_x_policy);
1924 struct sadb_x_ipsecrequest *rq = (void*)(pol+1); 1924 struct sadb_x_ipsecrequest *rq = (void*)(pol+1);
1925 1925
1926 if (pol->sadb_x_policy_len * 8 < sizeof(struct sadb_x_policy))
1927 return -EINVAL;
1928
1926 while (len >= sizeof(struct sadb_x_ipsecrequest)) { 1929 while (len >= sizeof(struct sadb_x_ipsecrequest)) {
1927 if ((err = parse_ipsecrequest(xp, rq)) < 0) 1930 if ((err = parse_ipsecrequest(xp, rq)) < 0)
1928 return err; 1931 return err;
@@ -2157,7 +2160,7 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_ev
2157 out_hdr->sadb_msg_type = event2poltype(c->event); 2160 out_hdr->sadb_msg_type = event2poltype(c->event);
2158 out_hdr->sadb_msg_errno = 0; 2161 out_hdr->sadb_msg_errno = 0;
2159 out_hdr->sadb_msg_seq = c->seq; 2162 out_hdr->sadb_msg_seq = c->seq;
2160 out_hdr->sadb_msg_pid = c->pid; 2163 out_hdr->sadb_msg_pid = c->portid;
2161 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp)); 2164 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp));
2162 return 0; 2165 return 0;
2163 2166
@@ -2272,7 +2275,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, const struct sadb_
2272 c.event = XFRM_MSG_NEWPOLICY; 2275 c.event = XFRM_MSG_NEWPOLICY;
2273 2276
2274 c.seq = hdr->sadb_msg_seq; 2277 c.seq = hdr->sadb_msg_seq;
2275 c.pid = hdr->sadb_msg_pid; 2278 c.portid = hdr->sadb_msg_pid;
2276 2279
2277 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); 2280 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c);
2278 xfrm_pol_put(xp); 2281 xfrm_pol_put(xp);
@@ -2351,7 +2354,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, const struct sa
2351 goto out; 2354 goto out;
2352 2355
2353 c.seq = hdr->sadb_msg_seq; 2356 c.seq = hdr->sadb_msg_seq;
2354 c.pid = hdr->sadb_msg_pid; 2357 c.portid = hdr->sadb_msg_pid;
2355 c.data.byid = 0; 2358 c.data.byid = 0;
2356 c.event = XFRM_MSG_DELPOLICY; 2359 c.event = XFRM_MSG_DELPOLICY;
2357 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); 2360 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c);
@@ -2597,7 +2600,7 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, const struct sadb_
2597 if (err) 2600 if (err)
2598 goto out; 2601 goto out;
2599 c.seq = hdr->sadb_msg_seq; 2602 c.seq = hdr->sadb_msg_seq;
2600 c.pid = hdr->sadb_msg_pid; 2603 c.portid = hdr->sadb_msg_pid;
2601 c.data.byid = 1; 2604 c.data.byid = 1;
2602 c.event = XFRM_MSG_DELPOLICY; 2605 c.event = XFRM_MSG_DELPOLICY;
2603 km_policy_notify(xp, dir, &c); 2606 km_policy_notify(xp, dir, &c);
@@ -2634,7 +2637,7 @@ static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr)
2634 out_hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC; 2637 out_hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC;
2635 out_hdr->sadb_msg_errno = 0; 2638 out_hdr->sadb_msg_errno = 0;
2636 out_hdr->sadb_msg_seq = count + 1; 2639 out_hdr->sadb_msg_seq = count + 1;
2637 out_hdr->sadb_msg_pid = pfk->dump.msg_pid; 2640 out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
2638 2641
2639 if (pfk->dump.skb) 2642 if (pfk->dump.skb)
2640 pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE, 2643 pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
@@ -2663,7 +2666,7 @@ static int pfkey_spddump(struct sock *sk, struct sk_buff *skb, const struct sadb
2663 return -EBUSY; 2666 return -EBUSY;
2664 2667
2665 pfk->dump.msg_version = hdr->sadb_msg_version; 2668 pfk->dump.msg_version = hdr->sadb_msg_version;
2666 pfk->dump.msg_pid = hdr->sadb_msg_pid; 2669 pfk->dump.msg_portid = hdr->sadb_msg_pid;
2667 pfk->dump.dump = pfkey_dump_sp; 2670 pfk->dump.dump = pfkey_dump_sp;
2668 pfk->dump.done = pfkey_dump_sp_done; 2671 pfk->dump.done = pfkey_dump_sp_done;
2669 xfrm_policy_walk_init(&pfk->dump.u.policy, XFRM_POLICY_TYPE_MAIN); 2672 xfrm_policy_walk_init(&pfk->dump.u.policy, XFRM_POLICY_TYPE_MAIN);
@@ -2682,7 +2685,7 @@ static int key_notify_policy_flush(const struct km_event *c)
2682 hdr = (struct sadb_msg *) skb_put(skb_out, sizeof(struct sadb_msg)); 2685 hdr = (struct sadb_msg *) skb_put(skb_out, sizeof(struct sadb_msg));
2683 hdr->sadb_msg_type = SADB_X_SPDFLUSH; 2686 hdr->sadb_msg_type = SADB_X_SPDFLUSH;
2684 hdr->sadb_msg_seq = c->seq; 2687 hdr->sadb_msg_seq = c->seq;
2685 hdr->sadb_msg_pid = c->pid; 2688 hdr->sadb_msg_pid = c->portid;
2686 hdr->sadb_msg_version = PF_KEY_V2; 2689 hdr->sadb_msg_version = PF_KEY_V2;
2687 hdr->sadb_msg_errno = (uint8_t) 0; 2690 hdr->sadb_msg_errno = (uint8_t) 0;
2688 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); 2691 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
@@ -2711,7 +2714,7 @@ static int pfkey_spdflush(struct sock *sk, struct sk_buff *skb, const struct sad
2711 2714
2712 c.data.type = XFRM_POLICY_TYPE_MAIN; 2715 c.data.type = XFRM_POLICY_TYPE_MAIN;
2713 c.event = XFRM_MSG_FLUSHPOLICY; 2716 c.event = XFRM_MSG_FLUSHPOLICY;
2714 c.pid = hdr->sadb_msg_pid; 2717 c.portid = hdr->sadb_msg_pid;
2715 c.seq = hdr->sadb_msg_seq; 2718 c.seq = hdr->sadb_msg_seq;
2716 c.net = net; 2719 c.net = net;
2717 km_policy_notify(NULL, 0, &c); 2720 km_policy_notify(NULL, 0, &c);
@@ -3024,7 +3027,7 @@ static u32 get_acqseq(void)
3024 return res; 3027 return res;
3025} 3028}
3026 3029
3027static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *xp, int dir) 3030static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *xp)
3028{ 3031{
3029 struct sk_buff *skb; 3032 struct sk_buff *skb;
3030 struct sadb_msg *hdr; 3033 struct sadb_msg *hdr;
@@ -3105,7 +3108,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
3105 pol->sadb_x_policy_len = sizeof(struct sadb_x_policy)/sizeof(uint64_t); 3108 pol->sadb_x_policy_len = sizeof(struct sadb_x_policy)/sizeof(uint64_t);
3106 pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY; 3109 pol->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
3107 pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC; 3110 pol->sadb_x_policy_type = IPSEC_POLICY_IPSEC;
3108 pol->sadb_x_policy_dir = dir+1; 3111 pol->sadb_x_policy_dir = XFRM_POLICY_OUT + 1;
3109 pol->sadb_x_policy_id = xp->index; 3112 pol->sadb_x_policy_id = xp->index;
3110 3113
3111 /* Set sadb_comb's. */ 3114 /* Set sadb_comb's. */