aboutsummaryrefslogtreecommitdiffstats
path: root/package/libnl-tiny/src/include/linux/if_addr.h
blob: 43f3bedaafd3c295c29f57082a7d51aaeb4f0bfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef __LINUX_IF_ADDR_H
#define __LINUX_IF_ADDR_H

#include <linux/netlink.h>

struct ifaddrmsg
{
	__u8		ifa_family;
	__u8		ifa_prefixlen;	/* The prefix length		*/
	__u8		ifa_flags;	/* Flags			*/
	__u8		ifa_scope;	/* Address scope		*/
	__u32		ifa_index;	/* Link index			*/
};

/*
 * Important comment:
 * IFA_ADDRESS is prefix address, rather than local interface address.
 * It makes no difference for normally configured broadcast interfaces,
 * but for point-to-point IFA_ADDRESS is DESTINATION address,
 * local address is supplied in IFA_LOCAL attribute.
 */
enum
{
	IFA_UNSPEC,
	IFA_ADDRESS,
	IFA_LOCAL,
	IFA_LABEL,
	IFA_BROADCAST,
	IFA_ANYCAST,
	IFA_CACHEINFO,
	IFA_MULTICAST,
	__IFA_MAX,
};

#define IFA_MAX (__IFA_MAX - 1)

/* ifa_flags */
#define IFA_F_SECONDARY		0x01
#define IFA_F_TEMPORARY		IFA_F_SECONDARY

#define	IFA_F_NODAD		0x02
#define IFA_F_OPTIMISTIC	0x04
#define	IFA_F_HOMEADDRESS	0x10
#define IFA_F_DEPRECATED	0x20
#define IFA_F_TENTATIVE		0x40
#define IFA_F_PERMANENT		0x80

struct ifa_cacheinfo
{
	__u32	ifa_prefered;
	__u32	ifa_valid;
	__u32	cstamp; /* created timestamp, hundredths of seconds */
	__u32	tstamp; /* updated timestamp, hundredths of seconds */
};

/* backwards compatibility for userspace */
#ifndef __KERNEL__
#define IFA_RTA(r)  ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
#endif

#endif
or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ #include <xen/config.h> #include <xen/lib.h> #include <xen/kernel.h> #include <xen/init.h> #include <xen/sched.h> #include <xen/smp.h> #include <xen/spinlock.h> #include <xen/guest_access.h> #include <asm/current.h> #include <asm/msr.h> #include <asm/uaccess.h> #include <asm/processor.h> #include <asm/microcode.h> const struct microcode_ops *microcode_ops; static DEFINE_SPINLOCK(microcode_mutex); DEFINE_PER_CPU(struct ucode_cpu_info, ucode_cpu_info); struct microcode_info { unsigned int cpu; uint32_t buffer_size; int error; char buffer[1]; }; static void __microcode_fini_cpu(int cpu) { struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu); xfree(uci->mc.mc_valid); memset(uci, 0, sizeof(*uci)); } static void microcode_fini_cpu(int cpu) { spin_lock(&microcode_mutex); __microcode_fini_cpu(cpu); spin_unlock(&microcode_mutex); } int microcode_resume_cpu(int cpu) { int err; struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu); struct cpu_signature nsig; if ( !uci->mc.mc_valid ) return -EIO; /* * Let's verify that the 'cached' ucode does belong * to this cpu (a bit of paranoia): */ err = microcode_ops->collect_cpu_info(cpu, &nsig); if ( err ) { microcode_fini_cpu(cpu); return err; } if ( microcode_ops->microcode_resume_match(cpu, &nsig) ) { return microcode_ops->apply_microcode(cpu); } else { microcode_fini_cpu(cpu); return -EIO; } } static int microcode_update_cpu(const void *buf, size_t size) { int err; unsigned int cpu = smp_processor_id(); struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu); spin_lock(&microcode_mutex); err = microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); if ( likely(!err) ) err = microcode_ops->cpu_request_microcode(cpu, buf, size); else __microcode_fini_cpu(cpu); spin_unlock(&microcode_mutex); return err; } static long do_microcode_update(void *_info) { struct microcode_info *info = _info; int error; BUG_ON(info->cpu != smp_processor_id()); error = microcode_update_cpu(info->buffer, info->buffer_size); if ( error ) info->error = error; info->cpu = next_cpu(info->cpu, cpu_online_map); if ( info->cpu < NR_CPUS ) return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info); error = info->error; xfree(info); return error; } int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) { int ret; struct microcode_info *info; if ( len != (uint32_t)len ) return -E2BIG; if ( microcode_ops == NULL ) return -EINVAL; info = xmalloc_bytes(sizeof(*info) + len); if ( info == NULL ) return -ENOMEM; ret = copy_from_guest(info->buffer, buf, len); if ( ret != 0 ) { xfree(info); return ret; } info->buffer_size = len; info->error = 0; info->cpu = first_cpu(cpu_online_map); return continue_hypercall_on_cpu(info->cpu, do_microcode_update, info); }