/* * writing 'C' to /proc/sysrq-trigger is like sysrq-C */ static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct ve_struct *cur = get_exec_env(); static int pnum = 10; if (count) { int i, cnt; char c[32]; cnt = min(count, sizeof(c)); if (copy_from_user(c, buf, cnt)) return -EFAULT; for (i = 0; i < cnt && c[i] != '\n'; i++) { if (!ve_is_super(cur)) { if (!pnum) continue; printk("SysRq: CT#%u sent '%c' magic key.\n", cur->veid, c[i]); pnum--; continue; } __handle_sysrq(c[i], NULL, 0); } } return count; }
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); }
void vlan_setup(struct net_device *dev) { ether_setup(dev); dev->priv_flags |= IFF_802_1Q_VLAN; dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; dev->tx_queue_len = 0; dev->netdev_ops = &vlan_netdev_ops; dev->destructor = free_netdev; dev->ethtool_ops = &vlan_ethtool_ops; memset(dev->broadcast, 0, ETH_ALEN); if (!ve_is_super(get_exec_env())) dev->features |= NETIF_F_VIRTUAL; }
static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat ) { struct ve_struct *ve = get_exec_env(); generic_fillattr(dentry->d_inode, stat); stat->nlink = glob_proc_root.nlink; if (ve_is_super(ve)) stat->nlink += nr_processes(); #ifdef CONFIG_VE else /* thread count. not really processes count */ stat->nlink += ve->pcounter; /* the same logic as in the proc_getattr */ stat->nlink += ve->proc_root->nlink - 2; #endif return 0; }
static int show_cpuinfo(struct seq_file *m, void *v) { struct cpuinfo_x86 *c = v; unsigned int cpu; int is_super = ve_is_super(get_exec_env()); int i; cpu = c->cpu_index; seq_printf(m, "processor\t: %u\n" "vendor_id\t: %s\n" "cpu family\t: %d\n" "model\t\t: %u\n" "model name\t: %s\n", cpu, c->x86_vendor_id[0] ? c->x86_vendor_id : "unknown", c->x86, c->x86_model, c->x86_model_id[0] ? c->x86_model_id : "unknown"); if (c->x86_mask || c->cpuid_level >= 0) seq_printf(m, "stepping\t: %d\n", c->x86_mask); else seq_printf(m, "stepping\t: unknown\n"); if (c->microcode) seq_printf(m, "microcode\t: 0x%x\n", c->microcode); if (cpu_has(c, X86_FEATURE_TSC)) { unsigned int freq = cpufreq_quick_get(cpu); if (!freq) freq = cpu_khz; freq = sched_cpulimit_scale_cpufreq(freq); seq_printf(m, "cpu MHz\t\t: %u.%03u\n", freq / 1000, (freq % 1000)); } /* Cache size */ if (c->x86_cache_size >= 0) seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size); show_cpuinfo_core(m, c, cpu); show_cpuinfo_misc(m, c); seq_printf(m, "flags\t\t:"); for (i = 0; i < 32*NCAPINTS; i++) if (x86_cap_flags[i] != NULL && ((is_super && cpu_has(c, i)) || (!is_super && test_bit(i, (unsigned long *) &per_cpu(cpu_flags, cpu))))) seq_printf(m, " %s", x86_cap_flags[i]); seq_printf(m, "\nbogomips\t: %lu.%02lu\n", c->loops_per_jiffy/(500000/HZ), (c->loops_per_jiffy/(5000/HZ)) % 100); #ifdef CONFIG_X86_64 if (c->x86_tlbsize > 0) seq_printf(m, "TLB size\t: %d 4K pages\n", c->x86_tlbsize); #endif seq_printf(m, "clflush size\t: %u\n", c->x86_clflush_size); seq_printf(m, "cache_alignment\t: %d\n", c->x86_cache_alignment); seq_printf(m, "address sizes\t: %u bits physical, %u bits virtual\n", c->x86_phys_bits, c->x86_virt_bits); seq_printf(m, "power management:"); for (i = 0; i < 32; i++) { if (c->x86_power & (1 << i)) { if (i < ARRAY_SIZE(x86_power_flags) && x86_power_flags[i]) seq_printf(m, "%s%s", x86_power_flags[i][0] ? " " : "", x86_power_flags[i]); else seq_printf(m, " [%d]", i); } } seq_printf(m, "\n\n"); return 0; }