~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to net/sunrpc/svcsock.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include <linux/kernel.h>
23
23
#include <linux/sched.h>
 
24
#include <linux/module.h>
24
25
#include <linux/errno.h>
25
26
#include <linux/fcntl.h>
26
27
#include <linux/net.h>
51
52
#include <linux/sunrpc/stats.h>
52
53
#include <linux/sunrpc/xprt.h>
53
54
 
 
55
#include "sunrpc.h"
 
56
 
54
57
#define RPCDBG_FACILITY RPCDBG_SVCXPRT
55
58
 
56
59
 
66
69
static struct svc_xprt *svc_create_socket(struct svc_serv *, int,
67
70
                                          struct net *, struct sockaddr *,
68
71
                                          int, int);
69
 
#if defined(CONFIG_NFS_V4_1)
 
72
#if defined(CONFIG_SUNRPC_BACKCHANNEL)
70
73
static struct svc_xprt *svc_bc_create_socket(struct svc_serv *, int,
71
74
                                             struct net *, struct sockaddr *,
72
75
                                             int, int);
73
76
static void svc_bc_sock_free(struct svc_xprt *xprt);
74
 
#endif /* CONFIG_NFS_V4_1 */
 
77
#endif /* CONFIG_SUNRPC_BACKCHANNEL */
75
78
 
76
79
#ifdef CONFIG_DEBUG_LOCK_ALLOC
77
80
static struct lock_class_key svc_key[2];
141
144
                        cmh->cmsg_level = SOL_IP;
142
145
                        cmh->cmsg_type = IP_PKTINFO;
143
146
                        pki->ipi_ifindex = 0;
144
 
                        pki->ipi_spec_dst.s_addr = rqstp->rq_daddr.addr.s_addr;
 
147
                        pki->ipi_spec_dst.s_addr =
 
148
                                 svc_daddr_in(rqstp)->sin_addr.s_addr;
145
149
                        cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
146
150
                }
147
151
                break;
148
152
 
149
153
        case AF_INET6: {
150
154
                        struct in6_pktinfo *pki = CMSG_DATA(cmh);
 
155
                        struct sockaddr_in6 *daddr = svc_daddr_in6(rqstp);
151
156
 
152
157
                        cmh->cmsg_level = SOL_IPV6;
153
158
                        cmh->cmsg_type = IPV6_PKTINFO;
154
 
                        pki->ipi6_ifindex = 0;
155
 
                        ipv6_addr_copy(&pki->ipi6_addr,
156
 
                                        &rqstp->rq_daddr.addr6);
 
159
                        pki->ipi6_ifindex = daddr->sin6_scope_id;
 
160
                        ipv6_addr_copy(&pki->ipi6_addr, &daddr->sin6_addr);
157
161
                        cmh->cmsg_len = CMSG_LEN(sizeof(*pki));
158
162
                }
159
163
                break;
496
500
                                     struct cmsghdr *cmh)
497
501
{
498
502
        struct in_pktinfo *pki = CMSG_DATA(cmh);
 
503
        struct sockaddr_in *daddr = svc_daddr_in(rqstp);
 
504
 
499
505
        if (cmh->cmsg_type != IP_PKTINFO)
500
506
                return 0;
501
 
        rqstp->rq_daddr.addr.s_addr = pki->ipi_spec_dst.s_addr;
 
507
 
 
508
        daddr->sin_family = AF_INET;
 
509
        daddr->sin_addr.s_addr = pki->ipi_spec_dst.s_addr;
502
510
        return 1;
503
511
}
504
512
 
509
517
                                     struct cmsghdr *cmh)
510
518
{
511
519
        struct in6_pktinfo *pki = CMSG_DATA(cmh);
 
520
        struct sockaddr_in6 *daddr = svc_daddr_in6(rqstp);
 
521
 
512
522
        if (cmh->cmsg_type != IPV6_PKTINFO)
513
523
                return 0;
514
 
        ipv6_addr_copy(&rqstp->rq_daddr.addr6, &pki->ipi6_addr);
 
524
 
 
525
        daddr->sin6_family = AF_INET6;
 
526
        ipv6_addr_copy(&daddr->sin6_addr, &pki->ipi6_addr);
 
527
        daddr->sin6_scope_id = pki->ipi6_ifindex;
515
528
        return 1;
516
529
}
517
530
 
612
625
                skb_free_datagram_locked(svsk->sk_sk, skb);
613
626
                return 0;
614
627
        }
 
628
        rqstp->rq_daddrlen = svc_addr_len(svc_daddr(rqstp));
615
629
 
616
630
        if (skb_is_nonlinear(skb)) {
617
631
                /* we have to copy */
1241
1255
        return svc_create_socket(serv, IPPROTO_TCP, net, sa, salen, flags);
1242
1256
}
1243
1257
 
1244
 
#if defined(CONFIG_NFS_V4_1)
 
1258
#if defined(CONFIG_SUNRPC_BACKCHANNEL)
1245
1259
static struct svc_xprt *svc_bc_create_socket(struct svc_serv *, int,
1246
1260
                                             struct net *, struct sockaddr *,
1247
1261
                                             int, int);
1282
1296
{
1283
1297
        svc_unreg_xprt_class(&svc_tcp_bc_class);
1284
1298
}
1285
 
#else /* CONFIG_NFS_V4_1 */
 
1299
#else /* CONFIG_SUNRPC_BACKCHANNEL */
1286
1300
static void svc_init_bc_xprt_sock(void)
1287
1301
{
1288
1302
}
1290
1304
static void svc_cleanup_bc_xprt_sock(void)
1291
1305
{
1292
1306
}
1293
 
#endif /* CONFIG_NFS_V4_1 */
 
1307
#endif /* CONFIG_SUNRPC_BACKCHANNEL */
1294
1308
 
1295
1309
static struct svc_xprt_ops svc_tcp_ops = {
1296
1310
        .xpo_create = svc_tcp_create,
1621
1635
        kfree(svsk);
1622
1636
}
1623
1637
 
1624
 
#if defined(CONFIG_NFS_V4_1)
 
1638
#if defined(CONFIG_SUNRPC_BACKCHANNEL)
1625
1639
/*
1626
1640
 * Create a back channel svc_xprt which shares the fore channel socket.
1627
1641
 */
1660
1674
        if (xprt)
1661
1675
                kfree(container_of(xprt, struct svc_sock, sk_xprt));
1662
1676
}
1663
 
#endif /* CONFIG_NFS_V4_1 */
 
1677
#endif /* CONFIG_SUNRPC_BACKCHANNEL */