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

« back to all changes in this revision

Viewing changes to net/netfilter/ipvs/ip_vs_app.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
EXPORT_SYMBOL(unregister_ip_vs_app);
44
44
EXPORT_SYMBOL(register_ip_vs_app_inc);
45
45
 
46
 
/* ipvs application list head */
47
 
static LIST_HEAD(ip_vs_app_list);
48
46
static DEFINE_MUTEX(__ip_vs_app_mutex);
49
47
 
50
 
 
51
48
/*
52
49
 *      Get an ip_vs_app object
53
50
 */
67
64
 *      Allocate/initialize app incarnation and register it in proto apps.
68
65
 */
69
66
static int
70
 
ip_vs_app_inc_new(struct ip_vs_app *app, __u16 proto, __u16 port)
 
67
ip_vs_app_inc_new(struct net *net, struct ip_vs_app *app, __u16 proto,
 
68
                  __u16 port)
71
69
{
72
70
        struct ip_vs_protocol *pp;
73
71
        struct ip_vs_app *inc;
98
96
                }
99
97
        }
100
98
 
101
 
        ret = pp->register_app(inc);
 
99
        ret = pp->register_app(net, inc);
102
100
        if (ret)
103
101
                goto out;
104
102
 
119
117
 *      Release app incarnation
120
118
 */
121
119
static void
122
 
ip_vs_app_inc_release(struct ip_vs_app *inc)
 
120
ip_vs_app_inc_release(struct net *net, struct ip_vs_app *inc)
123
121
{
124
122
        struct ip_vs_protocol *pp;
125
123
 
127
125
                return;
128
126
 
129
127
        if (pp->unregister_app)
130
 
                pp->unregister_app(inc);
 
128
                pp->unregister_app(net, inc);
131
129
 
132
130
        IP_VS_DBG(9, "%s App %s:%u unregistered\n",
133
131
                  pp->name, inc->name, ntohs(inc->port));
168
166
 *      Register an application incarnation in protocol applications
169
167
 */
170
168
int
171
 
register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port)
 
169
register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app, __u16 proto,
 
170
                       __u16 port)
172
171
{
173
172
        int result;
174
173
 
175
174
        mutex_lock(&__ip_vs_app_mutex);
176
175
 
177
 
        result = ip_vs_app_inc_new(app, proto, port);
 
176
        result = ip_vs_app_inc_new(net, app, proto, port);
178
177
 
179
178
        mutex_unlock(&__ip_vs_app_mutex);
180
179
 
185
184
/*
186
185
 *      ip_vs_app registration routine
187
186
 */
188
 
int register_ip_vs_app(struct ip_vs_app *app)
 
187
int register_ip_vs_app(struct net *net, struct ip_vs_app *app)
189
188
{
 
189
        struct netns_ipvs *ipvs = net_ipvs(net);
190
190
        /* increase the module use count */
191
191
        ip_vs_use_count_inc();
192
192
 
193
193
        mutex_lock(&__ip_vs_app_mutex);
194
194
 
195
 
        list_add(&app->a_list, &ip_vs_app_list);
 
195
        list_add(&app->a_list, &ipvs->app_list);
196
196
 
197
197
        mutex_unlock(&__ip_vs_app_mutex);
198
198
 
204
204
 *      ip_vs_app unregistration routine
205
205
 *      We are sure there are no app incarnations attached to services
206
206
 */
207
 
void unregister_ip_vs_app(struct ip_vs_app *app)
 
207
void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app)
208
208
{
209
209
        struct ip_vs_app *inc, *nxt;
210
210
 
211
211
        mutex_lock(&__ip_vs_app_mutex);
212
212
 
213
213
        list_for_each_entry_safe(inc, nxt, &app->incs_list, a_list) {
214
 
                ip_vs_app_inc_release(inc);
 
214
                ip_vs_app_inc_release(net, inc);
215
215
        }
216
216
 
217
217
        list_del(&app->a_list);
226
226
/*
227
227
 *      Bind ip_vs_conn to its ip_vs_app (called by cp constructor)
228
228
 */
229
 
int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp)
 
229
int ip_vs_bind_app(struct ip_vs_conn *cp,
 
230
                   struct ip_vs_protocol *pp)
230
231
{
231
232
        return pp->app_conn_bind(cp);
232
233
}
481
482
 *      /proc/net/ip_vs_app entry function
482
483
 */
483
484
 
484
 
static struct ip_vs_app *ip_vs_app_idx(loff_t pos)
 
485
static struct ip_vs_app *ip_vs_app_idx(struct netns_ipvs *ipvs, loff_t pos)
485
486
{
486
487
        struct ip_vs_app *app, *inc;
487
488
 
488
 
        list_for_each_entry(app, &ip_vs_app_list, a_list) {
 
489
        list_for_each_entry(app, &ipvs->app_list, a_list) {
489
490
                list_for_each_entry(inc, &app->incs_list, a_list) {
490
491
                        if (pos-- == 0)
491
492
                                return inc;
497
498
 
498
499
static void *ip_vs_app_seq_start(struct seq_file *seq, loff_t *pos)
499
500
{
 
501
        struct net *net = seq_file_net(seq);
 
502
        struct netns_ipvs *ipvs = net_ipvs(net);
 
503
 
500
504
        mutex_lock(&__ip_vs_app_mutex);
501
505
 
502
 
        return *pos ? ip_vs_app_idx(*pos - 1) : SEQ_START_TOKEN;
 
506
        return *pos ? ip_vs_app_idx(ipvs, *pos - 1) : SEQ_START_TOKEN;
503
507
}
504
508
 
505
509
static void *ip_vs_app_seq_next(struct seq_file *seq, void *v, loff_t *pos)
506
510
{
507
511
        struct ip_vs_app *inc, *app;
508
512
        struct list_head *e;
 
513
        struct net *net = seq_file_net(seq);
 
514
        struct netns_ipvs *ipvs = net_ipvs(net);
509
515
 
510
516
        ++*pos;
511
517
        if (v == SEQ_START_TOKEN)
512
 
                return ip_vs_app_idx(0);
 
518
                return ip_vs_app_idx(ipvs, 0);
513
519
 
514
520
        inc = v;
515
521
        app = inc->app;
518
524
                return list_entry(e, struct ip_vs_app, a_list);
519
525
 
520
526
        /* go on to next application */
521
 
        for (e = app->a_list.next; e != &ip_vs_app_list; e = e->next) {
 
527
        for (e = app->a_list.next; e != &ipvs->app_list; e = e->next) {
522
528
                app = list_entry(e, struct ip_vs_app, a_list);
523
529
                list_for_each_entry(inc, &app->incs_list, a_list) {
524
530
                        return inc;
557
563
 
558
564
static int ip_vs_app_open(struct inode *inode, struct file *file)
559
565
{
560
 
        return seq_open(file, &ip_vs_app_seq_ops);
 
566
        return seq_open_net(inode, file, &ip_vs_app_seq_ops,
 
567
                            sizeof(struct seq_net_private));
561
568
}
562
569
 
563
570
static const struct file_operations ip_vs_app_fops = {
565
572
        .open    = ip_vs_app_open,
566
573
        .read    = seq_read,
567
574
        .llseek  = seq_lseek,
568
 
        .release = seq_release,
 
575
        .release = seq_release_net,
569
576
};
570
577
#endif
571
578
 
 
579
int __net_init __ip_vs_app_init(struct net *net)
 
580
{
 
581
        struct netns_ipvs *ipvs = net_ipvs(net);
 
582
 
 
583
        INIT_LIST_HEAD(&ipvs->app_list);
 
584
        proc_net_fops_create(net, "ip_vs_app", 0, &ip_vs_app_fops);
 
585
        return 0;
 
586
}
 
587
 
 
588
void __net_exit __ip_vs_app_cleanup(struct net *net)
 
589
{
 
590
        proc_net_remove(net, "ip_vs_app");
 
591
}
 
592
 
572
593
int __init ip_vs_app_init(void)
573
594
{
574
 
        /* we will replace it with proc_net_ipvs_create() soon */
575
 
        proc_net_fops_create(&init_net, "ip_vs_app", 0, &ip_vs_app_fops);
576
595
        return 0;
577
596
}
578
597
 
579
598
 
580
599
void ip_vs_app_cleanup(void)
581
600
{
582
 
        proc_net_remove(&init_net, "ip_vs_app");
583
601
}