/* * Create devtmpfs instance, driver-core devices will add their device * nodes here. */ int __init devtmpfs_init(void) { int err; struct vfsmount *mnt; char options[] = "mode=0755"; err = register_filesystem(&dev_fs_type); if (err) { printk(KERN_ERR "devtmpfs: unable to register devtmpfs " "type %i\n", err); return err; } mnt = kern_mount_data(&dev_fs_type, options); if (IS_ERR(mnt)) { err = PTR_ERR(mnt); printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err); unregister_filesystem(&dev_fs_type); return err; } #ifdef CONFIG_VE get_ve0()->devtmpfs_mnt = mnt; #else dev_mnt = mnt; #endif printk(KERN_INFO "devtmpfs: initialized\n"); return 0; }
void __init proc_root_init(void) { int err; proc_init_inodecache(); err = register_filesystem(&proc_fs_type); if (err) return; #ifdef CONFIG_VE get_ve0()->proc_root = &proc_root; #endif proc_mnt = kern_mount_data(&proc_fs_type, &init_pid_ns); err = PTR_ERR(proc_mnt); if (IS_ERR(proc_mnt)) { unregister_filesystem(&proc_fs_type); return; } proc_symlink("mounts", &glob_proc_root, "self/mounts"); #ifdef CONFIG_VE get_ve0()->proc_mnt = proc_mnt; #endif proc_net_init(); #ifdef CONFIG_SYSVIPC proc_mkdir("sysvipc", &glob_proc_root); #endif proc_mkdir("fs", &glob_proc_root); proc_mkdir("fs", NULL); /* care about proc_mkdir("fs/xxx", NULL); */ proc_mkdir("driver", NULL); proc_mkdir("fs/nfsd", &glob_proc_root); /* somewhere for the nfsd filesystem to be mounted */ #if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE) /* just give it a mountpoint */ proc_mkdir("openprom", NULL); #endif proc_tty_init(); #ifdef CONFIG_PROC_DEVICETREE proc_device_tree_init(); #endif proc_mkdir("bus", NULL); proc_sys_init(); }
static int __init br_init(void) { int err; err = stp_proto_register(&br_stp_proto); if (err < 0) { printk(KERN_ERR "bridge: can't register sap for STP\n"); return err; } err = br_fdb_init(); if (err) goto err_out; err = register_pernet_subsys(&br_net_ops); if (err) goto err_out1; err = br_netfilter_init(); if (err) goto err_out2; err = register_netdevice_notifier(&br_device_notifier); if (err) goto err_out3; err = br_netlink_init(); if (err) goto err_out4; get_ve0()->features |= VE_FEATURE_BRIDGE; brioctl_set(br_ioctl_deviceless_stub); br_handle_frame_hook = br_handle_frame; br_hard_xmit_hook = br_xmit; #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE) br_fdb_test_addr_hook = br_fdb_test_addr; #endif return 0; err_out4: unregister_netdevice_notifier(&br_device_notifier); err_out3: br_netfilter_fini(); err_out2: unregister_pernet_subsys(&br_net_ops); err_out1: br_fdb_fini(); err_out: stp_proto_unregister(&br_stp_proto); return err; }
static struct ve_struct *veip_lookup(struct sk_buff *skb) { struct ve_struct *ve, *ve_old; int dir; struct ve_addr_struct addr; ve_old = skb->owner_env; dir = ve_is_super(ve_old); if (skb_extract_addr(skb, &addr, dir) < 0) goto out_drop_nolock; rcu_read_lock(); if (!dir) { /* from VE to host */ ve = venet_find_ve(&addr, 0); if (ve == NULL) { if (!venet_ext_lookup(ve_old, &addr)) goto out_drop; } else { if (!ve_accessible_strict(ve, ve_old)) goto out_source; } ve = get_ve0(); } else { /* from host to VE */ ve = venet_find_ve(&addr, 1); if (ve == NULL) goto out_drop; } rcu_read_unlock(); return ve; out_drop: rcu_read_unlock(); out_drop_nolock: return ERR_PTR(-ESRCH); out_source: rcu_read_unlock(); if (net_ratelimit() && skb->protocol == __constant_htons(ETH_P_IP)) { printk(KERN_WARNING "Dropped packet, source wrong " "veid=%u src-IP=%u.%u.%u.%u " "dst-IP=%u.%u.%u.%u\n", skb->owner_env->veid, NIPQUAD(ip_hdr(skb)->saddr), NIPQUAD(ip_hdr(skb)->daddr)); } return ERR_PTR(-EACCES); }
int vzevent_send(int event, const char *attrs_fmt, ...) { va_list args; int len, err; struct ve_struct *ve; char *page; err = -ENOMEM; page = (char *)__get_free_page(GFP_KERNEL); if (!page) goto out; va_start(args, attrs_fmt); len = vscnprintf(page, PAGE_SIZE, attrs_fmt, args); va_end(args); ve = set_exec_env(get_ve0()); err = do_vzevent_send(event, page, len); (void)set_exec_env(ve); free_page((unsigned long)page); out: return err; }
static int cpt_dump_iptables(struct cpt_context * ctx) { int err = 0; #ifdef CONFIG_VE_IPTABLES int pid; int pfd[2]; struct file *f; struct cpt_object_hdr v; char buf[16]; loff_t pos; int n; int status; mm_segment_t oldfs; sigset_t ignore, blocked; struct args_t args; struct ve_struct *oldenv; if (!(get_exec_env()->_iptables_modules & VE_IP_IPTABLES_MOD)) return 0; err = sc_pipe(pfd); if (err < 0) { eprintk_ctx("sc_pipe: %d\n", err); return err; } args.pfd = pfd; args.veid = VEID(get_exec_env()); ignore.sig[0] = CPT_SIG_IGNORE_MASK; sigprocmask(SIG_BLOCK, &ignore, &blocked); oldenv = set_exec_env(get_ve0()); err = pid = local_kernel_thread(dumpfn, (void*)&args, SIGCHLD | CLONE_VFORK, 0); set_exec_env(oldenv); if (err < 0) { eprintk_ctx("local_kernel_thread: %d\n", err); goto out; } f = fget(pfd[0]); sc_close(pfd[1]); sc_close(pfd[0]); cpt_open_section(ctx, CPT_SECT_NET_IPTABLES); cpt_open_object(NULL, ctx); v.cpt_next = CPT_NULL; v.cpt_object = CPT_OBJ_NAME; v.cpt_hdrlen = sizeof(v); v.cpt_content = CPT_CONTENT_NAME; ctx->write(&v, sizeof(v), ctx); pos = ctx->file->f_pos; do { oldfs = get_fs(); set_fs(KERNEL_DS); n = f->f_op->read(f, buf, sizeof(buf), &f->f_pos); set_fs(oldfs); if (n > 0) ctx->write(buf, n, ctx); } while (n > 0); if (n < 0) eprintk_ctx("read: %d\n", n); fput(f); oldfs = get_fs(); set_fs(KERNEL_DS); if ((err = sc_waitx(pid, 0, &status)) < 0) eprintk_ctx("wait4: %d\n", err); else if ((status & 0x7f) == 0) { err = (status & 0xff00) >> 8; if (err != 0) { eprintk_ctx("iptables-save exited with %d\n", err); err = -EINVAL; } } else {