* [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe().
From: Michael Chan @ 2010-06-15 18:57 UTC (permalink / raw)
To: davem; +Cc: netdev
In-Reply-To: <1276628223-27125-1-git-send-email-mchan@broadcom.com>
Move chip-specific code to the respective chip's ->close_conn() functions
for better code organization.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: Eddie Wai <waie@broadcom.com>
---
drivers/net/cnic.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index b20e11c..48fdbce 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -3143,12 +3143,6 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe)
break;
case L4_KCQE_OPCODE_VALUE_RESET_RECEIVED:
- if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) {
- cnic_cm_upcall(cp, csk, opcode);
- break;
- } else if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags))
- csk->state = opcode;
- /* fall through */
case L4_KCQE_OPCODE_VALUE_CLOSE_COMP:
case L4_KCQE_OPCODE_VALUE_RESET_COMP:
case L5CM_RAMROD_CMD_ID_SEARCHER_DELETE:
@@ -3204,6 +3198,10 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev)
static int cnic_ready_to_close(struct cnic_sock *csk, u32 opcode)
{
+ if (opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED) {
+ if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags))
+ csk->state = opcode;
+ }
if ((opcode == csk->state) ||
(opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED &&
csk->state == L4_KCQE_OPCODE_VALUE_CLOSE_COMP)) {
@@ -3228,6 +3226,11 @@ static void cnic_close_bnx2_conn(struct cnic_sock *csk, u32 opcode)
struct cnic_dev *dev = csk->dev;
struct cnic_local *cp = dev->cnic_priv;
+ if (opcode == L4_KCQE_OPCODE_VALUE_RESET_RECEIVED) {
+ cnic_cm_upcall(cp, csk, opcode);
+ return;
+ }
+
clear_bit(SK_F_CONNECT_START, &csk->flags);
cnic_close_conn(csk);
cnic_cm_upcall(cp, csk, opcode);
--
1.6.4.GIT
^ permalink raw reply related
* Re: [PATCH v2] tcp: unify tcp flag macros
From: David Miller @ 2010-06-15 18:56 UTC (permalink / raw)
To: xiaosuo; +Cc: kuznet, pekkas, jmorris, yoshfuji, kaber, netdev, netfilter-devel
In-Reply-To: <1276387303-25892-1-git-send-email-xiaosuo@gmail.com>
From: Changli Gao <xiaosuo@gmail.com>
Date: Sun, 13 Jun 2010 08:01:43 +0800
> unify tcp flag macros: TCPHDR_FIN, TCPHDR_SYN, TCPHDR_RST, TCPHDR_PSH,
> TCPHDR_ACK, TCPHDR_URG, TCPHDR_ECE and TCPHDR_CWR. TCBCB_FLAG_* are replaced
> with the corresponding TCPHDR_*.
>
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH 0/1] netfilter: netfilter fixes
From: David Miller @ 2010-06-15 18:59 UTC (permalink / raw)
To: kaber; +Cc: netfilter-devel, netdev
In-Reply-To: <1276613285-4959-1-git-send-email-kaber@trash.net>
From: kaber@trash.net
Date: Tue, 15 Jun 2010 16:48:04 +0200
> following is a single netfilter fix for IPVS from Sven Wegener, fixing a race
> condition that might result in an oops.
>
> Please apply or pull from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git master
Pulled, thanks Patrick.
^ permalink raw reply
* Re: [PATCH 08/12] ptp: Added a brand new class driver for ptp clocks.
From: Grant Likely @ 2010-06-15 19:11 UTC (permalink / raw)
To: Richard Cochran
Cc: netdev, devicetree-discuss, linuxppc-dev, linux-arm-kernel,
Krzysztof Halasa, Thomas Gleixner
In-Reply-To: <4a030d2bace90f089f2f3f61496b918c6f1dfb52.1276615626.git.richard.cochran@omicron.at>
On Tue, Jun 15, 2010 at 10:09 AM, Richard Cochran
<richardcochran@gmail.com> wrote:
> This patch adds an infrastructure for hardware clocks that implement
> IEEE 1588, the Precision Time Protocol (PTP). A class driver offers a
> registration method to particular hardware clock drivers. Each clock is
> exposed to user space as a character device with ioctls that allow tuning
> of the PTP clock.
>
> Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
Hi Richard,
Some more comments on this patch...
> ---
> Documentation/ptp/ptp.txt | 95 +++++++
> Documentation/ptp/testptp.c | 269 ++++++++++++++++++++
> Documentation/ptp/testptp.mk | 33 +++
> drivers/Kconfig | 2 +
> drivers/Makefile | 1 +
> drivers/ptp/Kconfig | 26 ++
> drivers/ptp/Makefile | 5 +
> drivers/ptp/ptp_clock.c | 514 ++++++++++++++++++++++++++++++++++++++
> include/linux/Kbuild | 1 +
> include/linux/ptp_clock.h | 79 ++++++
> include/linux/ptp_clock_kernel.h | 137 ++++++++++
> 11 files changed, 1162 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/ptp/ptp.txt
> create mode 100644 Documentation/ptp/testptp.c
> create mode 100644 Documentation/ptp/testptp.mk
> create mode 100644 drivers/ptp/Kconfig
> create mode 100644 drivers/ptp/Makefile
> create mode 100644 drivers/ptp/ptp_clock.c
> create mode 100644 include/linux/ptp_clock.h
> create mode 100644 include/linux/ptp_clock_kernel.h
>
> diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile
> new file mode 100644
> index 0000000..b86695c
> --- /dev/null
> +++ b/drivers/ptp/Makefile
> @@ -0,0 +1,5 @@
> +#
> +# Makefile for PTP 1588 clock support.
> +#
> +
> +obj-$(CONFIG_PTP_1588_CLOCK) += ptp_clock.o
> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> new file mode 100644
> index 0000000..4753bf3
> --- /dev/null
> +++ b/drivers/ptp/ptp_clock.c
> @@ -0,0 +1,514 @@
> +/*
> + * PTP 1588 clock support
> + *
> + * Partially adapted from the Linux PPS driver.
> + *
> + * Copyright (C) 2010 OMICRON electronics GmbH
> + *
> + * This program is free software; you can redistribute it and/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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +#include <linux/bitops.h>
> +#include <linux/cdev.h>
> +#include <linux/device.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/list.h>
> +#include <linux/module.h>
> +#include <linux/poll.h>
> +#include <linux/sched.h>
> +#include <linux/slab.h>
> +#include <linux/uaccess.h>
> +
> +#include <linux/ptp_clock_kernel.h>
> +#include <linux/ptp_clock.h>
> +
> +#define PTP_MAX_ALARMS 4
> +#define PTP_MAX_CLOCKS BITS_PER_LONG
> +#define PTP_MAX_TIMESTAMPS 128
> +
> +struct alarm {
> + struct pid *pid;
> + int sig;
> +};
> +
> +struct timestamp_event_queue {
> + struct ptp_extts_event buf[PTP_MAX_TIMESTAMPS];
> + int head;
> + int tail;
> + int overflow;
> +};
> +
> +struct ptp_clock {
> + struct list_head list;
> + struct cdev cdev;
> + struct device *dev;
> + struct ptp_clock_info *info;
> + dev_t devid;
> + int index; /* index into clocks.map, also the minor number */
> +
> + struct alarm alarm[PTP_MAX_ALARMS];
> + struct mutex alarm_mux; /* one process at a time setting an alarm */
> +
> + struct timestamp_event_queue tsevq; /* simple fifo for time stamps */
> + struct mutex tsevq_mux; /* one process at a time reading the fifo */
> + wait_queue_head_t tsev_wq;
> +};
> +
> +/* private globals */
> +
> +static const struct file_operations ptp_fops;
> +static dev_t ptp_devt;
> +static struct class *ptp_class;
> +
> +static struct {
> + struct list_head list;
> + DECLARE_BITMAP(map, PTP_MAX_CLOCKS);
> +} clocks;
> +static DEFINE_SPINLOCK(clocks_lock); /* protects 'clocks' */
Doesn't appear that clocks is manipulated at atomic context. Mutex instead?
> +
> +/* time stamp event queue operations */
> +
> +static inline int queue_cnt(struct timestamp_event_queue *q)
> +{
> + int cnt = q->tail - q->head;
> + return cnt < 0 ? PTP_MAX_TIMESTAMPS + cnt : cnt;
> +}
> +
> +static inline int queue_free(struct timestamp_event_queue *q)
> +{
> + return PTP_MAX_TIMESTAMPS - queue_cnt(q) - 1;
> +}
> +
> +static void enqueue_external_timestamp(struct timestamp_event_queue *queue,
> + struct ptp_clock_event *src)
> +{
> + struct ptp_extts_event *dst;
> + u32 remainder;
> +
> + dst = &queue->buf[queue->tail];
> +
> + dst->index = src->index;
> + dst->ts.tv_sec = div_u64_rem(src->timestamp, 1000000000, &remainder);
> + dst->ts.tv_nsec = remainder;
> +
> + if (!queue_free(queue))
> + queue->overflow++;
> +
> + queue->tail = (queue->tail + 1) % PTP_MAX_TIMESTAMPS;
> +}
> +
> +/* public interface */
> +
> +struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info)
> +{
> + struct ptp_clock *ptp;
> + int err = 0, index, major = MAJOR(ptp_devt);
> + unsigned long flags;
> +
> + if (info->n_alarm > PTP_MAX_ALARMS)
> + return ERR_PTR(-EINVAL);
Okay, this is my opinion here, and other maintainers may disagree with
me, but the ERR_PTR() pattern is a horrible idea. It is non-obvious
when reading code when the pattern is used, and the compiler will not
catch misinterpretation of the return value for you. Please don't add
new instances of using it. Just return NULL on error and log it with
printk() or pr_error(). Very seldom do I find the actual error code
to be actually useful anyway. Generally callers only care about
whether or not the operation succeeded.
> +
> + /* Find a free clock slot and reserve it. */
> + err = -EBUSY;
> + spin_lock_irqsave(&clocks_lock, flags);
> + index = find_first_zero_bit(clocks.map, PTP_MAX_CLOCKS);
> + if (index < PTP_MAX_CLOCKS) {
> + set_bit(index, clocks.map);
> + spin_unlock_irqrestore(&clocks_lock, flags);
> + } else {
> + spin_unlock_irqrestore(&clocks_lock, flags);
> + goto no_clock;
> + }
If the spinlock is changed to a mutex that is held for the entire
function call, then the logic here can be simpler.
> +
> + /* Initialize a clock structure. */
> + err = -ENOMEM;
> + ptp = kzalloc(sizeof(struct ptp_clock), GFP_KERNEL);
> + if (ptp == NULL)
> + goto no_memory;
> +
> + ptp->info = info;
> + ptp->devid = MKDEV(major, index);
> + ptp->index = index;
> + mutex_init(&ptp->alarm_mux);
> + mutex_init(&ptp->tsevq_mux);
> + init_waitqueue_head(&ptp->tsev_wq);
> +
> + /* Create a new device in our class. */
> + ptp->dev = device_create(ptp_class, NULL, ptp->devid, ptp,
> + "ptp_clock_%d", ptp->index);
> + if (IS_ERR(ptp->dev))
> + goto no_device;
> +
> + dev_set_drvdata(ptp->dev, ptp);
> +
> + /* Register a character device. */
> + cdev_init(&ptp->cdev, &ptp_fops);
> + ptp->cdev.owner = info->owner;
> + err = cdev_add(&ptp->cdev, ptp->devid, 1);
> + if (err)
> + goto no_cdev;
> +
> + /* Clock is ready, add it into the list. */
> + spin_lock_irqsave(&clocks_lock, flags);
> + list_add(&ptp->list, &clocks.list);
> + spin_unlock_irqrestore(&clocks_lock, flags);
> +
> + return ptp;
> +
> +no_cdev:
> + device_destroy(ptp_class, ptp->devid);
> +no_device:
> + mutex_destroy(&ptp->alarm_mux);
> + mutex_destroy(&ptp->tsevq_mux);
> + kfree(ptp);
> +no_memory:
> + spin_lock_irqsave(&clocks_lock, flags);
> + clear_bit(index, clocks.map);
> + spin_unlock_irqrestore(&clocks_lock, flags);
> +no_clock:
> + return ERR_PTR(err);
> +}
> +EXPORT_SYMBOL(ptp_clock_register);
> +
> +int ptp_clock_unregister(struct ptp_clock *ptp)
> +{
> + unsigned long flags;
> +
> + /* Release the clock's resources. */
> + cdev_del(&ptp->cdev);
> + device_destroy(ptp_class, ptp->devid);
> + mutex_destroy(&ptp->alarm_mux);
> + mutex_destroy(&ptp->tsevq_mux);
> +
> + /* Remove the clock from the list. */
> + spin_lock_irqsave(&clocks_lock, flags);
> + list_del(&ptp->list);
> + clear_bit(ptp->index, clocks.map);
> + spin_unlock_irqrestore(&clocks_lock, flags);
> +
> + kfree(ptp);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(ptp_clock_unregister);
> +
> +void ptp_clock_event(struct ptp_clock *ptp, struct ptp_clock_event *event)
> +{
> + switch (event->type) {
> +
> + case PTP_CLOCK_ALARM:
> + kill_pid(ptp->alarm[event->index].pid,
> + ptp->alarm[event->index].sig, 1);
> + break;
> +
> + case PTP_CLOCK_EXTTS:
> + enqueue_external_timestamp(&ptp->tsevq, event);
> + wake_up_interruptible(&ptp->tsev_wq);
> + break;
> +
> + case PTP_CLOCK_PPS:
> + break;
> + }
> +}
> +EXPORT_SYMBOL(ptp_clock_event);
> +
> +/* character device operations */
> +
> +static int ptp_ioctl(struct inode *node, struct file *fp,
> + unsigned int cmd, unsigned long arg)
> +{
> + struct ptp_clock_caps caps;
> + struct ptp_clock_request req;
> + struct ptp_clock_timer timer;
> + struct ptp_clock *ptp = fp->private_data;
> + struct ptp_clock_info *ops = ptp->info;
> + void *priv = ops->priv;
> + struct timespec ts;
> + int flags, index;
> + int err = 0;
> +
> + switch (cmd) {
> +
> + case PTP_CLOCK_APIVERS:
> + err = put_user(PTP_CLOCK_VERSION, (u32 __user *)arg);
> + break;
> +
> + case PTP_CLOCK_ADJFREQ:
> + if (!capable(CAP_SYS_TIME))
> + return -EPERM;
> + err = ops->adjfreq(priv, arg);
> + break;
> +
> + case PTP_CLOCK_ADJTIME:
> + if (!capable(CAP_SYS_TIME))
> + return -EPERM;
> + if (copy_from_user(&ts, (void __user *)arg, sizeof(ts)))
> + err = -EFAULT;
> + else
> + err = ops->adjtime(priv, &ts);
> + break;
> +
> + case PTP_CLOCK_GETTIME:
> + err = ops->gettime(priv, &ts);
> + if (err)
> + break;
> + err = copy_to_user((void __user *)arg, &ts, sizeof(ts));
> + break;
> +
> + case PTP_CLOCK_SETTIME:
> + if (!capable(CAP_SYS_TIME))
> + return -EPERM;
> + if (copy_from_user(&ts, (void __user *)arg, sizeof(ts)))
> + err = -EFAULT;
> + else
> + err = ops->settime(priv, &ts);
> + break;
> +
> + case PTP_CLOCK_GETCAPS:
> + memset(&caps, 0, sizeof(caps));
> + caps.max_adj = ptp->info->max_adj;
> + caps.n_alarm = ptp->info->n_alarm;
> + caps.n_ext_ts = ptp->info->n_ext_ts;
> + caps.n_per_out = ptp->info->n_per_out;
> + caps.pps = ptp->info->pps;
> + err = copy_to_user((void __user *)arg, &caps, sizeof(caps));
> + break;
> +
> + case PTP_CLOCK_GETTIMER:
> + if (copy_from_user(&timer, (void __user *)arg, sizeof(timer))) {
> + err = -EFAULT;
> + break;
> + }
> + index = timer.alarm_index;
> + if (index < 0 || index >= ptp->info->n_alarm) {
> + err = -EINVAL;
> + break;
> + }
> + err = ops->gettimer(priv, index, &timer.tsp);
> + if (err)
> + break;
> + err = copy_to_user((void __user *)arg, &timer, sizeof(timer));
> + break;
> +
> + case PTP_CLOCK_SETTIMER:
> + if (copy_from_user(&timer, (void __user *)arg, sizeof(timer))) {
> + err = -EFAULT;
> + break;
> + }
> + index = timer.alarm_index;
> + if (index < 0 || index >= ptp->info->n_alarm) {
> + err = -EINVAL;
> + break;
> + }
> + if (!valid_signal(timer.signum))
> + return -EINVAL;
> + flags = timer.flags;
> + if (flags & (flags != TIMER_ABSTIME)) {
> + err = -EINVAL;
> + break;
> + }
> + if (mutex_lock_interruptible(&ptp->alarm_mux))
> + return -ERESTARTSYS;
> +
> + if (ptp->alarm[index].pid)
> + put_pid(ptp->alarm[index].pid);
> +
> + ptp->alarm[index].pid = get_pid(task_pid(current));
> + ptp->alarm[index].sig = timer.signum;
> + err = ops->settimer(priv, index, flags, &timer.tsp);
> +
> + mutex_unlock(&ptp->alarm_mux);
> + break;
> +
> + case PTP_FEATURE_REQUEST:
> + if (copy_from_user(&req, (void __user *)arg, sizeof(req))) {
> + err = -EFAULT;
> + break;
> + }
> + switch (req.type) {
> + case PTP_REQUEST_EXTTS:
> + case PTP_REQUEST_PEROUT:
> + break;
> + case PTP_REQUEST_PPS:
> + if (!capable(CAP_SYS_TIME))
> + return -EPERM;
> + break;
> + default:
> + err = -EINVAL;
> + break;
> + }
> + if (err)
> + break;
> + err = ops->enable(priv, &req,
> + req.flags & PTP_ENABLE_FEATURE ? 1 : 0);
> + break;
> +
> + default:
> + err = -ENOTTY;
> + break;
> + }
> + return err;
> +}
> +
> +static int ptp_open(struct inode *inode, struct file *fp)
> +{
> + struct ptp_clock *ptp;
> + ptp = container_of(inode->i_cdev, struct ptp_clock, cdev);
> +
> + fp->private_data = ptp;
> +
> + return 0;
> +}
> +
> +static unsigned int ptp_poll(struct file *fp, poll_table *wait)
> +{
> + struct ptp_clock *ptp = fp->private_data;
> +
> + poll_wait(fp, &ptp->tsev_wq, wait);
> +
> + return queue_cnt(&ptp->tsevq) ? POLLIN : 0;
> +}
> +
> +static ssize_t ptp_read(struct file *fp, char __user *buf,
> + size_t cnt, loff_t *off)
> +{
> + struct ptp_clock *ptp = fp->private_data;
> + struct timestamp_event_queue *queue = &ptp->tsevq;
> + struct ptp_extts_event *event;
> + size_t qcnt;
> +
> + if (mutex_lock_interruptible(&ptp->tsevq_mux))
> + return -ERESTARTSYS;
> +
> + cnt = cnt / sizeof(struct ptp_extts_event);
> +
> + if (wait_event_interruptible(ptp->tsev_wq,
> + (qcnt = queue_cnt(&ptp->tsevq)))) {
> + mutex_unlock(&ptp->tsevq_mux);
> + return -ERESTARTSYS;
> + }
> +
> + if (cnt > qcnt)
> + cnt = qcnt;
> +
> + event = &queue->buf[queue->head];
> +
> + if (copy_to_user(buf, event, cnt * sizeof(struct ptp_extts_event))) {
> + mutex_unlock(&ptp->tsevq_mux);
> + return -EFAULT;
> + }
> + queue->head = (queue->head + cnt) % PTP_MAX_TIMESTAMPS;
> +
> + mutex_unlock(&ptp->tsevq_mux);
> +
> + return cnt * sizeof(struct ptp_extts_event);
> +}
> +
> +static int ptp_release(struct inode *inode, struct file *fp)
> +{
> + struct ptp_clock *ptp;
> + struct itimerspec ts = {
> + {0, 0}, {0, 0}
> + };
> + int i;
> +
> + ptp = container_of(inode->i_cdev, struct ptp_clock, cdev);
> +
> + for (i = 0; i < ptp->info->n_alarm; i++) {
> + if (ptp->alarm[i].pid) {
> + ptp->info->settimer(ptp->info->priv, i, 0, &ts);
> + put_pid(ptp->alarm[i].pid);
> + ptp->alarm[i].pid = NULL;
> + }
> + }
> + return 0;
> +}
> +
> +static const struct file_operations ptp_fops = {
> + .owner = THIS_MODULE,
> + .ioctl = ptp_ioctl,
> + .open = ptp_open,
> + .poll = ptp_poll,
> + .read = ptp_read,
> + .release = ptp_release,
> +};
> +
> +/* sysfs */
> +
> +static ssize_t ptp_show_status(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct ptp_clock *ptp = dev_get_drvdata(dev);
> + return sprintf(buf,
> + "maximum adjustment: %d\n"
> + "programmable alarms: %d\n"
> + "external timestamps: %d\n"
> + "periodic outputs: %d\n"
> + "has pps: %d\n"
> + "device index: %d\n",
> + ptp->info->max_adj,
> + ptp->info->n_alarm,
> + ptp->info->n_ext_ts,
> + ptp->info->n_per_out,
> + ptp->info->pps,
> + ptp->index);
> +}
Don't do this in a sysfs file. Use a debugfs file if you want to
export freeform data like this. sysfs files should contain either
only one value, or a simple list-of-same-type values. Formatted data
is completely out.
> +
> +struct device_attribute ptp_attrs[] = {
> + __ATTR(capabilities, S_IRUGO, ptp_show_status, NULL),
> + __ATTR_NULL,
> +};
> +
> +/* module operations */
> +
> +static void __exit ptp_exit(void)
> +{
> + class_destroy(ptp_class);
> + unregister_chrdev_region(ptp_devt, PTP_MAX_CLOCKS);
> +}
> +
> +static int __init ptp_init(void)
> +{
> + int err;
> +
> + INIT_LIST_HEAD(&clocks.list);
> +
> + ptp_class = class_create(THIS_MODULE, "ptp");
> + if (!ptp_class) {
> + printk(KERN_ERR "ptp: failed to allocate class\n");
> + return -ENOMEM;
> + }
> + ptp_class->dev_attrs = ptp_attrs;
> +
> + err = alloc_chrdev_region(&ptp_devt, 0, PTP_MAX_CLOCKS, "ptp");
> + if (err < 0) {
> + printk(KERN_ERR "ptp: failed to allocate char device region\n");
> + goto no_region;
> + }
> +
> + pr_info("PTP clock support registered\n");
> + return 0;
> +
> +no_region:
> + class_destroy(ptp_class);
> + return err;
> +}
> +
> +subsys_initcall(ptp_init);
> +module_exit(ptp_exit);
> +
> +MODULE_AUTHOR("Richard Cochran <richard.cochran@omicron.at>");
> +MODULE_DESCRIPTION("PTP clocks support");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/Kbuild b/include/linux/Kbuild
> index 2fc8e14..9959fe4 100644
> --- a/include/linux/Kbuild
> +++ b/include/linux/Kbuild
> @@ -140,6 +140,7 @@ header-y += pkt_sched.h
> header-y += posix_types.h
> header-y += ppdev.h
> header-y += prctl.h
> +header-y += ptp_clock.h
> header-y += qnxtypes.h
> header-y += qnx4_fs.h
> header-y += radeonfb.h
> diff --git a/include/linux/ptp_clock.h b/include/linux/ptp_clock.h
> new file mode 100644
> index 0000000..5a509c5
> --- /dev/null
> +++ b/include/linux/ptp_clock.h
> @@ -0,0 +1,79 @@
> +/*
> + * PTP 1588 clock support - user space interface
> + *
> + * Copyright (C) 2010 OMICRON electronics GmbH
> + *
> + * This program is free software; you can redistribute it and/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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#ifndef _PTP_CLOCK_H_
> +#define _PTP_CLOCK_H_
> +
> +#include <linux/ioctl.h>
> +#include <linux/types.h>
> +
> +#define PTP_ENABLE_FEATURE (1<<0)
> +#define PTP_RISING_EDGE (1<<1)
> +#define PTP_FALLING_EDGE (1<<2)
> +
> +enum ptp_request_types {
> + PTP_REQUEST_EXTTS,
> + PTP_REQUEST_PEROUT,
> + PTP_REQUEST_PPS,
> +};
> +
> +struct ptp_clock_caps {
> + __s32 max_adj; /* Maximum frequency adjustment, parts per billon. */
> + int n_alarm; /* Number of programmable alarms. */
> + int n_ext_ts; /* Number of external time stamp channels. */
> + int n_per_out; /* Number of programmable periodic signals. */
> + int pps; /* Whether the clock supports a PPS callback. */
> +};
> +
> +struct ptp_clock_timer {
> + int alarm_index; /* Which alarm to query or configure. */
> + int signum; /* Requested signal. */
> + int flags; /* Zero or TIMER_ABSTIME, see TIMER_SETTIME(2) */
> + struct itimerspec tsp; /* See TIMER_SETTIME(2) */
> +};
> +
> +struct ptp_clock_request {
> + int type; /* One of the ptp_request_types enumeration values. */
> + int index; /* Which channel to configure. */
> + struct timespec ts; /* For period signals, the desired period. */
> + int flags; /* Bit field for PTP_ENABLE_FEATURE or other flags. */
> +};
> +
> +struct ptp_extts_event {
> + int index;
> + struct timespec ts;
> +};
> +
> +#define PTP_CLOCK_VERSION 0x00000001
> +
> +#define PTP_CLK_MAGIC '='
> +
> +#define PTP_CLOCK_APIVERS _IOR (PTP_CLK_MAGIC, 1, __u32)
> +#define PTP_CLOCK_ADJFREQ _IO (PTP_CLK_MAGIC, 2)
> +#define PTP_CLOCK_ADJTIME _IOW (PTP_CLK_MAGIC, 3, struct timespec)
> +#define PTP_CLOCK_GETTIME _IOR (PTP_CLK_MAGIC, 4, struct timespec)
> +#define PTP_CLOCK_SETTIME _IOW (PTP_CLK_MAGIC, 5, struct timespec)
> +
> +#define PTP_CLOCK_GETCAPS _IOR (PTP_CLK_MAGIC, 6, struct ptp_clock_caps)
> +#define PTP_CLOCK_GETTIMER _IOWR (PTP_CLK_MAGIC, 7, struct ptp_clock_timer)
> +#define PTP_CLOCK_SETTIMER _IOW (PTP_CLK_MAGIC, 8, struct ptp_clock_timer)
> +#define PTP_FEATURE_REQUEST _IOW (PTP_CLK_MAGIC, 9, struct ptp_clock_request)
> +
> +#endif
> diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
> new file mode 100644
> index 0000000..d6cc158
> --- /dev/null
> +++ b/include/linux/ptp_clock_kernel.h
> @@ -0,0 +1,137 @@
> +/*
> + * PTP 1588 clock support
> + *
> + * Copyright (C) 2010 OMICRON electronics GmbH
> + *
> + * This program is free software; you can redistribute it and/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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +
> +#ifndef _PTP_CLOCK_KERNEL_H_
> +#define _PTP_CLOCK_KERNEL_H_
> +
> +#include <linux/ptp_clock.h>
> +
> +/**
> + * struct ptp_clock_info - decribes a PTP hardware clock
> + *
> + * @owner: The clock driver should set to THIS_MODULE.
> + * @name: A short name to identify the clock.
> + * @max_adj: The maximum possible frequency adjustment, in parts per billon.
> + * @n_alarm: The number of programmable alarms.
> + * @n_ext_ts: The number of external time stamp channels.
> + * @n_per_out: The number of programmable periodic signals.
> + * @pps: Indicates whether the clock supports a PPS callback.
> + * @priv: Passed to the clock operations, for the driver's private use.
> + *
> + * clock operations
> + *
> + * @adjfreq: Adjusts the frequency of the hardware clock.
> + * parameter delta: Desired period change in parts per billion.
> + *
> + * @adjtime: Shifts the time of the hardware clock.
> + * parameter ts: Desired change in seconds and nanoseconds.
> + *
> + * @gettime: Reads the current time from the hardware clock.
> + * parameter ts: Holds the result.
> + *
> + * @settime: Set the current time on the hardware clock.
> + * parameter ts: Time value to set.
> + *
> + * @gettimer: Reads the time remaining from the given timer.
> + * parameter index: Which alarm to query.
> + * parameter ts: Holds the result.
> + *
> + * @settimer: Arms the given timer for periodic or one shot operation.
> + * parameter index: Which alarm to set.
> + * parameter abs: TIMER_ABSTIME, or zero for relative timer.
> + * parameter ts: Alarm time and period to set.
> + *
> + * @enable: Request driver to enable or disable an ancillary feature.
> + * parameter request: Desired resource to enable or disable.
> + * parameter on: Caller passes one to enable or zero to disable.
> + *
> + * The callbacks must all return zero on success, non-zero otherwise.
> + */
> +
> +struct ptp_clock_info {
> + struct module *owner;
> + char name[16];
> + s32 max_adj;
> + int n_alarm;
> + int n_ext_ts;
> + int n_per_out;
> + int pps;
> + void *priv;
> + int (*adjfreq)(void *priv, s32 delta);
> + int (*adjtime)(void *priv, struct timespec *ts);
> + int (*gettime)(void *priv, struct timespec *ts);
> + int (*settime)(void *priv, struct timespec *ts);
> + int (*gettimer)(void *priv, int index, struct itimerspec *ts);
> + int (*settimer)(void *priv, int index, int abs, struct itimerspec *ts);
> + int (*enable)(void *priv, struct ptp_clock_request *request, int on);
> +};
> +
> +struct ptp_clock;
> +
> +/**
> + * ptp_clock_register() - register a PTP hardware clock driver
> + *
> + * @info: Structure describing the new clock.
> + */
> +
> +extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info);
> +
> +/**
> + * ptp_clock_unregister() - unregister a PTP hardware clock driver
> + *
> + * @ptp: The clock to remove from service.
> + */
> +
> +extern int ptp_clock_unregister(struct ptp_clock *ptp);
> +
> +
> +enum ptp_clock_events {
> + PTP_CLOCK_ALARM,
> + PTP_CLOCK_EXTTS,
> + PTP_CLOCK_PPS,
> +};
> +
> +/**
> + * struct ptp_clock_event - decribes a PTP hardware clock event
> + *
> + * @type: One of the ptp_clock_events enumeration values.
> + * @index: Identifies the source of the event.
> + * @timestamp: When the event occured.
> + */
> +
> +struct ptp_clock_event {
> + int type;
> + int index;
> + u64 timestamp;
> +};
> +
> +/**
> + * ptp_clock_event() - notify the PTP layer about an event
> + *
> + * This function should only be called from interrupt context.
> + *
> + * @ptp: The clock obtained from ptp_clock_register().
> + * @event: Message structure describing the event.
> + */
> +
> +extern void ptp_clock_event(struct ptp_clock *ptp,
> + struct ptp_clock_event *event);
> +
> +#endif
> --
> 1.6.3.3
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply
* [net-2.6 PATCH] ixgbe: add comment on SFP+ ID for Active DA
From: Jeff Kirsher @ 2010-06-15 19:23 UTC (permalink / raw)
To: davem; +Cc: netdev, gospo, bphilips, Don Skidmore, Jeff Kirsher
From: Don Skidmore <donald.c.skidmore@intel.com>
These comments were forgotten in the initial patch to add this
functionality. This patch corrects that.
Signed-off-by: Don Skidmore <donald.c.skidmore@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ixgbe/ixgbe_phy.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe_phy.c b/drivers/net/ixgbe/ixgbe_phy.c
index 09e1911..48325a5 100644
--- a/drivers/net/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ixgbe/ixgbe_phy.c
@@ -575,6 +575,8 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
* 4 SFP_DA_CORE1 - 82599-specific
* 5 SFP_SR/LR_CORE0 - 82599-specific
* 6 SFP_SR/LR_CORE1 - 82599-specific
+ * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
+ * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
*/
if (hw->mac.type == ixgbe_mac_82598EB) {
if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
^ permalink raw reply related
* [net-next-2.6 PATCH] ixgbe: update set_rx_mode to fix issues w/ macvlan
From: Jeff Kirsher @ 2010-06-15 19:25 UTC (permalink / raw)
To: davem; +Cc: netdev, gospo, bphilips, Shirley Ma, Alexander Duyck,
Jeff Kirsher
From: Alexander Duyck <alexander.h.duyck@intel.com>
This change corrects issues where macvlan was not correctly triggering
promiscuous mode on ixgbe due to the filters not being correctly set. It
also corrects the fact that VF rar filters were being overwritten when the
PF was reset.
CC: Shirley Ma <xma@us.ibm.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Tested-by: Emil Tantilov <emil.s.tantilov@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ixgbe/ixgbe.h | 1
drivers/net/ixgbe/ixgbe_main.c | 88 +++++++++++++++++++++++++++++++++------
drivers/net/ixgbe/ixgbe_sriov.c | 16 ++-----
3 files changed, 79 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index 9270089..9e15eb9 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -110,7 +110,6 @@ struct vf_data_storage {
u16 vlans_enabled;
bool clear_to_send;
bool pf_set_mac;
- int rar;
u16 pf_vlan; /* When set, guest VLAN config not allowed. */
u16 pf_qos;
};
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 9cca737..ebc4b04 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -2992,6 +2992,48 @@ static void ixgbe_restore_vlan(struct ixgbe_adapter *adapter)
}
/**
+ * ixgbe_write_uc_addr_list - write unicast addresses to RAR table
+ * @netdev: network interface device structure
+ *
+ * Writes unicast address list to the RAR table.
+ * Returns: -ENOMEM on failure/insufficient address space
+ * 0 on no addresses written
+ * X on writing X addresses to the RAR table
+ **/
+static int ixgbe_write_uc_addr_list(struct net_device *netdev)
+{
+ struct ixgbe_adapter *adapter = netdev_priv(netdev);
+ struct ixgbe_hw *hw = &adapter->hw;
+ unsigned int vfn = adapter->num_vfs;
+ unsigned int rar_entries = hw->mac.num_rar_entries - (vfn + 1);
+ int count = 0;
+
+ /* return ENOMEM indicating insufficient memory for addresses */
+ if (netdev_uc_count(netdev) > rar_entries)
+ return -ENOMEM;
+
+ if (!netdev_uc_empty(netdev) && rar_entries) {
+ struct netdev_hw_addr *ha;
+ /* return error if we do not support writing to RAR table */
+ if (!hw->mac.ops.set_rar)
+ return -ENOMEM;
+
+ netdev_for_each_uc_addr(ha, netdev) {
+ if (!rar_entries)
+ break;
+ hw->mac.ops.set_rar(hw, rar_entries--, ha->addr,
+ vfn, IXGBE_RAH_AV);
+ count++;
+ }
+ }
+ /* write the addresses in reverse order to avoid write combining */
+ for (; rar_entries > 0 ; rar_entries--)
+ hw->mac.ops.clear_rar(hw, rar_entries);
+
+ return count;
+}
+
+/**
* ixgbe_set_rx_mode - Unicast, Multicast and Promiscuous mode set
* @netdev: network interface device structure
*
@@ -3004,38 +3046,58 @@ void ixgbe_set_rx_mode(struct net_device *netdev)
{
struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_hw *hw = &adapter->hw;
- u32 fctrl;
+ u32 fctrl, vmolr = IXGBE_VMOLR_BAM | IXGBE_VMOLR_AUPE;
+ int count;
/* Check for Promiscuous and All Multicast modes */
fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
+ /* clear the bits we are changing the status of */
+ fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
+
if (netdev->flags & IFF_PROMISC) {
hw->addr_ctrl.user_set_promisc = true;
fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
+ vmolr |= (IXGBE_VMOLR_ROPE | IXGBE_VMOLR_MPE);
/* don't hardware filter vlans in promisc mode */
ixgbe_vlan_filter_disable(adapter);
} else {
if (netdev->flags & IFF_ALLMULTI) {
fctrl |= IXGBE_FCTRL_MPE;
- fctrl &= ~IXGBE_FCTRL_UPE;
- } else if (!hw->addr_ctrl.uc_set_promisc) {
- fctrl &= ~(IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
+ vmolr |= IXGBE_VMOLR_MPE;
+ } else {
+ /*
+ * Write addresses to the MTA, if the attempt fails
+ * then we should just turn on promiscous mode so
+ * that we can at least receive multicast traffic
+ */
+ hw->mac.ops.update_mc_addr_list(hw, netdev);
+ vmolr |= IXGBE_VMOLR_ROMPE;
}
ixgbe_vlan_filter_enable(adapter);
hw->addr_ctrl.user_set_promisc = false;
+ /*
+ * Write addresses to available RAR registers, if there is not
+ * sufficient space to store all the addresses then enable
+ * unicast promiscous mode
+ */
+ count = ixgbe_write_uc_addr_list(netdev);
+ if (count < 0) {
+ fctrl |= IXGBE_FCTRL_UPE;
+ vmolr |= IXGBE_VMOLR_ROPE;
+ }
}
- IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
-
- /* reprogram secondary unicast list */
- hw->mac.ops.update_uc_addr_list(hw, netdev);
-
- /* reprogram multicast list */
- hw->mac.ops.update_mc_addr_list(hw, netdev);
-
- if (adapter->num_vfs)
+ if (adapter->num_vfs) {
ixgbe_restore_vf_multicasts(adapter);
+ vmolr |= IXGBE_READ_REG(hw, IXGBE_VMOLR(adapter->num_vfs)) &
+ ~(IXGBE_VMOLR_MPE | IXGBE_VMOLR_ROMPE |
+ IXGBE_VMOLR_ROPE);
+ IXGBE_WRITE_REG(hw, IXGBE_VMOLR(adapter->num_vfs), vmolr);
+ }
+
+ IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
}
static void ixgbe_napi_enable_all(struct ixgbe_adapter *adapter)
diff --git a/drivers/net/ixgbe/ixgbe_sriov.c b/drivers/net/ixgbe/ixgbe_sriov.c
index 66f6e62..6e6dee0 100644
--- a/drivers/net/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ixgbe/ixgbe_sriov.c
@@ -137,6 +137,7 @@ static void ixgbe_set_vmvir(struct ixgbe_adapter *adapter, u32 vid, u32 vf)
inline void ixgbe_vf_reset_event(struct ixgbe_adapter *adapter, u32 vf)
{
struct ixgbe_hw *hw = &adapter->hw;
+ int rar_entry = hw->mac.num_rar_entries - (vf + 1);
/* reset offloads to defaults */
if (adapter->vfinfo[vf].pf_vlan) {
@@ -158,26 +159,17 @@ inline void ixgbe_vf_reset_event(struct ixgbe_adapter *adapter, u32 vf)
/* Flush and reset the mta with the new values */
ixgbe_set_rx_mode(adapter->netdev);
- if (adapter->vfinfo[vf].rar > 0) {
- adapter->hw.mac.ops.clear_rar(&adapter->hw,
- adapter->vfinfo[vf].rar);
- adapter->vfinfo[vf].rar = -1;
- }
+ hw->mac.ops.clear_rar(hw, rar_entry);
}
int ixgbe_set_vf_mac(struct ixgbe_adapter *adapter,
int vf, unsigned char *mac_addr)
{
struct ixgbe_hw *hw = &adapter->hw;
-
- adapter->vfinfo[vf].rar = hw->mac.ops.set_rar(hw, vf + 1, mac_addr,
- vf, IXGBE_RAH_AV);
- if (adapter->vfinfo[vf].rar < 0) {
- e_err("Could not set MAC Filter for VF %d\n", vf);
- return -1;
- }
+ int rar_entry = hw->mac.num_rar_entries - (vf + 1);
memcpy(adapter->vfinfo[vf].vf_mac_addresses, mac_addr, 6);
+ hw->mac.ops.set_rar(hw, rar_entry, mac_addr, vf, IXGBE_RAH_AV);
return 0;
}
^ permalink raw reply related
* Re: [PATCH 2/8] user_ns: Introduce user_nsmap_uid and user_ns_map_gid.
From: Serge E. Hallyn @ 2010-06-15 20:58 UTC (permalink / raw)
To: Eric W. Biederman
Cc: David Miller, Linux Containers, Serge Hallyn, Pavel Emelyanov,
netdev
In-Reply-To: <m17hm3hxjw.fsf_-_@fess.ebiederm.org>
Quoting Eric W. Biederman (ebiederm@xmission.com):
>
> Define what happens when a we view a uid from one user_namespace
> in another user_namepece.
>
> - If the user namespaces are the same no mapping is necessary.
>
> - For most cases of difference use overflowuid and overflowgid,
> the uid and gid currently used for 16bit apis when we have a 32bit uid
> that does fit in 16bits. Effectively the situation is the same,
> we want to return a uid or gid that is not assigned to any user.
>
> - For the case when we happen to be mapping the uid or gid of the
> creator of the target user namespace use uid 0 and gid as confusing
Looks good, except for 'uid 0 and gid' in commit msg will be confusing.
Just "use uid and gid 0".
> that user with root is not a problem.
>
> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Acked-by: Serge E. Hallyn <serue@us.ibm.com>
Mind you, like you I *am* still conflicted.
I believe the ideal behavior for the case where we're looking up a mapping
for a uid in a namespace created by ns, would be to return the creator's
uid, but then also support returning the POSIX capabilities targeted at
ns, which would be the empty set.
The path leading there is to start with this patch, then support sending
full credentials, and then we can modify this behavior.
(IMO)
thanks for pushing this.
-serge
> ---
> include/linux/user_namespace.h | 14 ++++++++++++
> kernel/user_namespace.c | 44 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 58 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
> index cc4f453..8178156 100644
> --- a/include/linux/user_namespace.h
> +++ b/include/linux/user_namespace.h
> @@ -36,6 +36,9 @@ static inline void put_user_ns(struct user_namespace *ns)
> kref_put(&ns->kref, free_user_ns);
> }
>
> +uid_t user_ns_map_uid(struct user_namespace *to, const struct cred *cred, uid_t uid);
> +gid_t user_ns_map_gid(struct user_namespace *to, const struct cred *cred, gid_t gid);
> +
> #else
>
> static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
> @@ -52,6 +55,17 @@ static inline void put_user_ns(struct user_namespace *ns)
> {
> }
>
> +static inline uid_t user_ns_map_uid(struct user_namespace *to,
> + const struct cred *cred, uid_t uid)
> +{
> + return uid;
> +}
> +static inline gid_t user_ns_map_gid(struct user_namespace *to,
> + const struct cred *cred, gid_t gid)
> +{
> + return gid;
> +}
> +
> #endif
>
> #endif /* _LINUX_USER_H */
> diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
> index 076c7c8..825abfb 100644
> --- a/kernel/user_namespace.c
> +++ b/kernel/user_namespace.c
> @@ -9,6 +9,7 @@
> #include <linux/nsproxy.h>
> #include <linux/slab.h>
> #include <linux/user_namespace.h>
> +#include <linux/highuid.h>
> #include <linux/cred.h>
>
> /*
> @@ -82,3 +83,46 @@ void free_user_ns(struct kref *kref)
> schedule_work(&ns->destroyer);
> }
> EXPORT_SYMBOL(free_user_ns);
> +
> +uid_t user_ns_map_uid(struct user_namespace *to, const struct cred *cred, uid_t uid)
> +{
> + struct user_namespace *tmp;
> +
> + if (likely(to == cred->user->user_ns))
> + return uid;
> +
> +
> + /* Is cred->user the creator of the target user_ns
> + * or the creator of one of it's parents?
> + */
> + for ( tmp = to; tmp != &init_user_ns;
> + tmp = tmp->creator->user_ns ) {
> + if (cred->user == tmp->creator) {
> + return (uid_t)0;
> + }
> + }
> +
> + /* No useful relationship so no mapping */
> + return overflowuid;
> +}
> +
> +gid_t user_ns_map_gid(struct user_namespace *to, const struct cred *cred, gid_t gid)
> +{
> + struct user_namespace *tmp;
> +
> + if (likely(to == cred->user->user_ns))
> + return gid;
> +
> + /* Is cred->user the creator of the target user_ns
> + * or the creator of one of it's parents?
> + */
> + for ( tmp = to; tmp != &init_user_ns;
> + tmp = tmp->creator->user_ns ) {
> + if (cred->user == tmp->creator) {
> + return (gid_t)0;
> + }
> + }
> +
> + /* No useful relationship so no mapping */
> + return overflowgid;
> +}
> --
> 1.6.5.2.143.g8cc62
>
> _______________________________________________
> Containers mailing list
> Containers@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
^ permalink raw reply
* Re: [PATCH 00/17] netfilter: netfilter update
From: David Miller @ 2010-06-15 21:19 UTC (permalink / raw)
To: kaber; +Cc: netfilter-devel, netdev
In-Reply-To: <1276616323-20880-1-git-send-email-kaber@trash.net>
From: kaber@trash.net
Date: Tue, 15 Jun 2010 17:38:26 +0200
> Please pull from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-next-2.6.git master
Pulled, thanks Patrick.
^ permalink raw reply
* Re: [net-next-2.6 PATCH] ixgbe: update set_rx_mode to fix issues w/ macvlan
From: David Miller @ 2010-06-15 21:24 UTC (permalink / raw)
To: jeffrey.t.kirsher; +Cc: netdev, gospo, bphilips, xma, alexander.h.duyck
In-Reply-To: <20100615192432.3011.29215.stgit@localhost.localdomain>
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Tue, 15 Jun 2010 12:25:48 -0700
> From: Alexander Duyck <alexander.h.duyck@intel.com>
>
> This change corrects issues where macvlan was not correctly triggering
> promiscuous mode on ixgbe due to the filters not being correctly set. It
> also corrects the fact that VF rar filters were being overwritten when the
> PF was reset.
>
> CC: Shirley Ma <xma@us.ibm.com>
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> Tested-by: Emil Tantilov <emil.s.tantilov@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next 1/4] cnic: Return error code in cnic_cm_close() if unsuccessful.
From: David Miller @ 2010-06-15 21:24 UTC (permalink / raw)
To: mchan; +Cc: netdev
In-Reply-To: <1276628223-27125-1-git-send-email-mchan@broadcom.com>
From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 15 Jun 2010 11:57:00 -0700
> So that bnx2i can handle the error condition immediately and not have to
> wait for timeout.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com.
> Signed-off-by: Eddie Wai <waie@broadcom.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next 2/4] cnic: Refactor code in cnic_cm_process_kcqe().
From: David Miller @ 2010-06-15 21:24 UTC (permalink / raw)
To: mchan; +Cc: netdev
In-Reply-To: <1276628223-27125-2-git-send-email-mchan@broadcom.com>
From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 15 Jun 2010 11:57:01 -0700
> Move chip-specific code to the respective chip's ->close_conn() functions
> for better code organization.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com>
> Signed-off-by: Eddie Wai <waie@broadcom.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next 3/4] cnic: Refactor and fix cnic_ready_to_close().
From: David Miller @ 2010-06-15 21:24 UTC (permalink / raw)
To: mchan; +Cc: netdev
In-Reply-To: <1276628223-27125-3-git-send-email-mchan@broadcom.com>
From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 15 Jun 2010 11:57:02 -0700
> Combine RESET_RECEIVED and RESET_COMP logic and fix race condition
> between these 2 events and cnic_cm_close(). In particular, we need
> to (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) before we
> update csk->state.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com>
> Signed-off-by: Eddie Wai <waie@broadcom.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next 4/4] cnic: Fix cnic_cm_abort() error handling.
From: David Miller @ 2010-06-15 21:24 UTC (permalink / raw)
To: mchan; +Cc: netdev
In-Reply-To: <1276628223-27125-4-git-send-email-mchan@broadcom.com>
From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 15 Jun 2010 11:57:03 -0700
> Fix the code that handles the error case when cnic_cm_abort() cannot
> proceed normally. We cannot just set the csk->state and we must
> go through cnic_ready_to_close() to handle all the conditions. We
> also add error return code in cnic_cm_abort().
>
> Signed-off-by: Michael Chan <mchan@broadcom.com>
> Signed-off-by: Eddie Wai <waie@broadcom.com>
Applied.
^ permalink raw reply
* Re: [PATCH net-next-2.6] inetpeer: RCU conversion
From: David Miller @ 2010-06-15 21:25 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, paulmck
In-Reply-To: <1276626194.2541.186.camel@edumazet-laptop>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 15 Jun 2010 20:23:14 +0200
> inetpeer currently uses an AVL tree protected by an rwlock.
>
> It's possible to make most lookups use RCU
...
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied, nice work Eric.
^ permalink raw reply
* Re: [Bugme-new] [Bug 16187] New: Carrier detection failed in dhcpcd when link is up
From: Andrew Morton @ 2010-06-15 21:24 UTC (permalink / raw)
To: netdev, Grant Grundler, Kyle McMartin
Cc: bugzilla-daemon, bugme-daemon, casteyde.christian
In-Reply-To: <bug-16187-10286@https.bugzilla.kernel.org/>
(switched to email. Please respond via emailed reply-to-all, not via the
bugzilla web interface).
On Sat, 12 Jun 2010 15:15:31 GMT
bugzilla-daemon@bugzilla.kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=16187
>
> Summary: Carrier detection failed in dhcpcd when link is up
> Product: Networking
> Version: 2.5
> Kernel Version: 2.6.35-rc2
> Platform: All
> OS/Version: Linux
> Tree: Mainline
> Status: NEW
> Severity: normal
> Priority: P1
> Component: Other
> AssignedTo: acme@ghostprotocols.net
> ReportedBy: casteyde.christian@free.fr
> Regression: Yes
>
>
> Created an attachment (id=26742)
> --> (https://bugzilla.kernel.org/attachment.cgi?id=26742)
> lspci output for 2.6.34 on my computer
>
> Kernel at least 2.6.35-rc2, 2.6.34 works fine
Seems to be post-2.6.34 breakage in the tulip driver.
> Athlon X2 3000 in 64bits mode
> Slackware 13.1
> "Ethernet controller: ALi Corporation ULi 1689,1573 integrated ethernet. (rev
> 40)" (from lspci)
>
> Since 2.6.35-rc2 (didn't checked -rc1), dhcpcd hangs fails to detect carrier
> appearance at boot.
>
> The Slackware network script uses dhcpcd to bring DHCP interfaces up. At boot,
> it seems my network device doesn't have the link up immediatly. dhcpcd tries to
> bring it up, and wait for the carrier. The carrier indeed goes up, but dhcpcd
> gets absolutly no notification of that, and therefore times out.
>
> logs says that:
> Jun 12 16:53:58 sirius logger: /etc/rc.d/rc.inet1: /sbin/route add -net
> 127.0.0.0 netmask 255.0.0.0 lo
> Jun 12 16:53:58 sirius logger: /etc/rc.d/rc.inet1: /sbin/dhcpcd -t 10 eth0
> Jun 12 16:53:58 sirius dhcpcd: version 5.2.2 starting
> Jun 12 16:53:58 sirius kernel: ADDRCONF(NETDEV_UP): eth0: link is not ready
> Jun 12 16:53:58 sirius dhcpcd: eth0: waiting for carrier
> Jun 12 16:54:01 sirius kernel: uli526x: eth0 NIC Link is Up 100 Mbps Full
> duplex
> Jun 12 16:54:01 sirius kernel: ADDRCONF(NETDEV_CHANGE): eth0: link becomes
> ready
> then dhcpcd times out a little later (10 seconds as -t 10 is specified).
>
> If I use the -K option (no carrier detection), and does ifconfig eth0 up just
> before issueing the dhcpcd command, dhcpcd doesn't wait for the carrier and
> gets a lease correctly.
>
> Reversely, with the 2.6.34 kernel, dhcpcd indeed gets the link up notification,
> and gets the lease immediatly. In this case, the log says:
>
> Jun 12 17:04:21 sirius logger: /etc/rc.d/rc.inet1: /sbin/route add -net
> 127.0.0.0 netmask 255.0.0.0 lo
> Jun 12 17:04:21 sirius logger: /etc/rc.d/rc.inet1: /sbin/dhcpcd -t 10 eth0
> Jun 12 17:04:22 sirius dhcpcd: version 5.2.2 starting
> Jun 12 17:04:22 sirius kernel: ADDRCONF(NETDEV_UP): eth0: link is not ready
> Jun 12 17:04:22 sirius dhcpcd: eth0: waiting for carrier
> Jun 12 17:04:25 sirius dhcpcd: eth0: carrier acquired
> Jun 12 17:04:25 sirius kernel: uli526x: eth0 NIC Link is Up 100 Mbps Full
> duplex
> Jun 12 17:04:25 sirius kernel: ADDRCONF(NETDEV_CHANGE): eth0: link becomes
> ready
> Jun 12 17:04:25 sirius dhcpcd: eth0: broadcasting for a lease
> Jun 12 17:04:29 sirius dhcpcd: eth0: offered 192.168.1.3 from 192.168.1.1
> Jun 12 17:04:29 sirius dhcpcd: eth0: acknowledged 192.168.1.3 from 192.168.1.1
> Jun 12 17:04:29 sirius dhcpcd: eth0: checking for 192.168.1.3
> Jun 12 17:04:34 sirius dhcpcd: eth0: leased 192.168.1.3 for 864000 seconds
> Jun 12 17:04:34 sirius dhcpcd: forking to background
>
> As you can see, dhcpcd asks for a lease as soon as the kernel tells it the link
> is up (message "carrier acquired").
>
> Therefore, I think 2.6.35-rc* notification of carrier is broken, and at least
> it broke dhcpcd way of watching the link.
>
^ permalink raw reply
* Re: [PATCH 6/8] scm: Capture the full credentials of the scm sender.
From: Serge E. Hallyn @ 2010-06-15 21:45 UTC (permalink / raw)
To: Eric W. Biederman
Cc: David Miller, Linux Containers, Serge Hallyn, Pavel Emelyanov,
netdev
In-Reply-To: <m1d3vvgirx.fsf@fess.ebiederm.org>
Quoting Eric W. Biederman (ebiederm@xmission.com):
>
> Start capturing not only the userspace pid, uid and gid values of the
> sending process but also the struct pid and struct cred of the sending
> process as well.
>
> This is in preparation for properly supporting SCM_CREDENTIALS for
> sockets that have different uid and/or pid namespaces at the different
> ends.
>
> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
> ---
> include/net/scm.h | 28 ++++++++++++++++++++++++----
> net/core/scm.c | 24 ++++++++++++++++++++++++
> 2 files changed, 48 insertions(+), 4 deletions(-)
>
> diff --git a/include/net/scm.h b/include/net/scm.h
> index 17d9d2e..3165650 100644
> --- a/include/net/scm.h
> +++ b/include/net/scm.h
> @@ -19,6 +19,8 @@ struct scm_fp_list {
> };
>
> struct scm_cookie {
> + struct pid *pid; /* Skb credentials */
> + const struct cred *cred;
> struct scm_fp_list *fp; /* Passed files */
> struct ucred creds; /* Skb credentials */
> #ifdef CONFIG_SECURITY_NETWORK
> @@ -42,8 +44,27 @@ static __inline__ void unix_get_peersec_dgram(struct socket *sock, struct scm_co
> { }
> #endif /* CONFIG_SECURITY_NETWORK */
>
> +static __inline__ void scm_set_cred(struct scm_cookie *scm,
> + struct pid *pid, const struct cred *cred)
> +{
> + scm->pid = get_pid(pid);
> + scm->cred = get_cred(cred);
> + cred_to_ucred(pid, cred, &scm->creds);
> +}
> +
> +static __inline__ void scm_destroy_cred(struct scm_cookie *scm)
> +{
> + put_pid(scm->pid);
> + scm->pid = NULL;
> +
> + if (scm->cred)
> + put_cred(scm->cred);
> + scm->cred = NULL;
> +}
> +
> static __inline__ void scm_destroy(struct scm_cookie *scm)
> {
> + scm_destroy_cred(scm);
> if (scm && scm->fp)
> __scm_destroy(scm);
> }
> @@ -51,10 +72,7 @@ static __inline__ void scm_destroy(struct scm_cookie *scm)
> static __inline__ int scm_send(struct socket *sock, struct msghdr *msg,
> struct scm_cookie *scm)
> {
> - struct task_struct *p = current;
> - scm->creds.uid = current_uid();
> - scm->creds.gid = current_gid();
> - scm->creds.pid = task_tgid_vnr(p);
> + scm_set_cred(scm, task_tgid(current), current_cred());
> scm->fp = NULL;
> unix_get_peersec_dgram(sock, scm);
> if (msg->msg_controllen <= 0)
> @@ -96,6 +114,8 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,
> if (test_bit(SOCK_PASSCRED, &sock->flags))
> put_cmsg(msg, SOL_SOCKET, SCM_CREDENTIALS, sizeof(scm->creds), &scm->creds);
>
> + scm_destroy_cred(scm);
> +
> scm_passec(sock, msg, scm);
>
> if (!scm->fp)
> diff --git a/net/core/scm.c b/net/core/scm.c
> index b88f6f9..681c976 100644
> --- a/net/core/scm.c
> +++ b/net/core/scm.c
> @@ -170,6 +170,30 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
> err = scm_check_creds(&p->creds);
> if (err)
> goto error;
> +
I think this hunk needs to be documented. I.e. given that scm_send()
will call scm_set_cred() before calling __scm_send, I don't see how
these conditions could happen? If the condition can legitimately
happen, then given all of the pid_t vs struct pid and 'cred' vs. 'creds'
in these two hunks, I think a comment over each would be nice.
> + if (pid_vnr(p->pid) != p->creds.pid) {
> + struct pid *pid;
> + err = -ESRCH;
> + pid = find_get_pid(p->creds.pid);
> + if (!pid)
> + goto error;
> + put_pid(p->pid);
> + p->pid = pid;
> + }
> +
> + if ((p->cred->euid != p->creds.uid) ||
> + (p->cred->egid != p->creds.gid)) {
> + struct cred *cred;
> + err = -ENOMEM;
> + cred = prepare_creds();
> + if (!cred)
> + goto error;
> +
> + cred->uid = cred->euid = p->creds.uid;
> + cred->gid = cred->egid = p->creds.uid;
> + put_cred(p->cred);
> + p->cred = cred;
> + }
> break;
> default:
> goto error;
> --
> 1.6.5.2.143.g8cc62
>
> _______________________________________________
> Containers mailing list
> Containers@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
^ permalink raw reply
* Re: [PATCH 2/2] pktgen: receive packets and process incoming rate
From: David Miller @ 2010-06-15 21:59 UTC (permalink / raw)
To: daniel.turull; +Cc: eric.dumazet, netdev, robert, jens.laas, voravit
In-Reply-To: <4C10F117.60800@gmail.com>
From: Daniel Turull <daniel.turull@gmail.com>
Date: Thu, 10 Jun 2010 16:05:11 +0200
> This patch adds receiver part to pktgen taking advantages of SMP systems
> with multiple rx queues:
> - Creation of new proc file /proc/net/pktgen/pgrx to control and display the receiver.
> - It uses PER-CPU variable to store the results per each CPU.
> - Results displayed per CPU and aggregated.
> - The packet handler is add in the protocols handlers (dev_add_pack())
> - Available statistics: packets and bytes received, work time and rate
> - Only process pktgen packets
> - It is possible to select the incoming interface
> - Documentation updated with the new commands to control the receiver part.
>
> Signed-off-by: Daniel Turull <daniel.turull@gmail.com>
I completely disagree with this patch on two levels:
1) pktgen is for "generating" packets, not receiving them.
Trying to put lipstick on a pig is never a good idea.
2) The information it gathers and shows is completely useless.
What's interesting as "RX work cost" is what happens deep
down in the netif_receive_skb() code paths, IP input, routing,
netfilter, whatever... but that is not what this thing is
measuring at all.
Sorry, I'm not applying this. You can probably do something more
clever with tracepoints.
^ permalink raw reply
* Re: [PATCH v4] netdev:bfin_mac: reclaim and free tx skb as soon as possible after transfer
From: David Miller @ 2010-06-15 22:04 UTC (permalink / raw)
To: sonic.adi; +Cc: netdev, uclinux-dist-devel
In-Reply-To: <1276250702.30044.2.camel@eight.analog.com>
From: sonic zhang <sonic.adi@gmail.com>
Date: Fri, 11 Jun 2010 18:05:02 +0800
>>From 4779e43a5a8446f695f8d6f5a006cfb45dc093d8 Mon Sep 17 00:00:00 2001
> From: Sonic Zhang <sonic.zhang@analog.com>
> Date: Fri, 11 Jun 2010 17:44:31 +0800
> Subject: [PATCH v4] netdev:bfin_mac: reclaim and free tx skb as soon as possible after transfer
>
> SKBs hold onto resources that can't be held indefinitely, such as TCP
> socket references and netfilter conntrack state. So if a packet is left
> in TX ring for a long time, there might be a TCP socket that cannot be
> closed and freed up.
>
> Current blackfin EMAC driver always reclaim and free used tx skbs in future
> transfers. The problem is that future transfer may not come as soon as
> possible. This patch start a timer after transfer to reclaim and free skb.
> There is nearly no performance drop with this patch.
>
> TX interrupt is not enabled because of a strange behavior of the Blackfin EMAC.
> If EMAC TX transfer control is turned on, endless TX interrupts are triggered
> no matter if TX DMA is enabled or not. Since DMA walks down the ring automatically,
> TX transfer control can't be turned off in the middle. The only way is to disable
> TX interrupt completely.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Applied to net-next-2.6, thanks.
^ permalink raw reply
* Re: [PATCH 6/8] scm: Capture the full credentials of the scm sender.
From: Eric W. Biederman @ 2010-06-15 22:08 UTC (permalink / raw)
To: Serge E. Hallyn
Cc: David Miller, Linux Containers, Serge Hallyn, Pavel Emelyanov,
netdev
In-Reply-To: <20100615214541.GA22570@hallyn.com>
"Serge E. Hallyn" <serge@hallyn.com> writes:
> Quoting Eric W. Biederman (ebiederm@xmission.com):
>>
>> Start capturing not only the userspace pid, uid and gid values of the
>> sending process but also the struct pid and struct cred of the sending
>> process as well.
>>
>> This is in preparation for properly supporting SCM_CREDENTIALS for
>> sockets that have different uid and/or pid namespaces at the different
>> ends.
>>
>> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
>> ---
>> include/net/scm.h | 28 ++++++++++++++++++++++++----
>> net/core/scm.c | 24 ++++++++++++++++++++++++
>> 2 files changed, 48 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/net/scm.h b/include/net/scm.h
>> index 17d9d2e..3165650 100644
>> --- a/include/net/scm.h
>> +++ b/include/net/scm.h
>> @@ -19,6 +19,8 @@ struct scm_fp_list {
>> };
>>
>> struct scm_cookie {
>> + struct pid *pid; /* Skb credentials */
>> + const struct cred *cred;
>> struct scm_fp_list *fp; /* Passed files */
>> struct ucred creds; /* Skb credentials */
>> #ifdef CONFIG_SECURITY_NETWORK
>> @@ -42,8 +44,27 @@ static __inline__ void unix_get_peersec_dgram(struct socket *sock, struct scm_co
>> { }
>> #endif /* CONFIG_SECURITY_NETWORK */
>>
>> +static __inline__ void scm_set_cred(struct scm_cookie *scm,
>> + struct pid *pid, const struct cred *cred)
>> +{
>> + scm->pid = get_pid(pid);
>> + scm->cred = get_cred(cred);
>> + cred_to_ucred(pid, cred, &scm->creds);
>> +}
>> +
>> +static __inline__ void scm_destroy_cred(struct scm_cookie *scm)
>> +{
>> + put_pid(scm->pid);
>> + scm->pid = NULL;
>> +
>> + if (scm->cred)
>> + put_cred(scm->cred);
>> + scm->cred = NULL;
>> +}
>> +
>> static __inline__ void scm_destroy(struct scm_cookie *scm)
>> {
>> + scm_destroy_cred(scm);
>> if (scm && scm->fp)
>> __scm_destroy(scm);
>> }
>> @@ -51,10 +72,7 @@ static __inline__ void scm_destroy(struct scm_cookie *scm)
>> static __inline__ int scm_send(struct socket *sock, struct msghdr *msg,
>> struct scm_cookie *scm)
>> {
>> - struct task_struct *p = current;
>> - scm->creds.uid = current_uid();
>> - scm->creds.gid = current_gid();
>> - scm->creds.pid = task_tgid_vnr(p);
>> + scm_set_cred(scm, task_tgid(current), current_cred());
>> scm->fp = NULL;
>> unix_get_peersec_dgram(sock, scm);
>> if (msg->msg_controllen <= 0)
>> @@ -96,6 +114,8 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,
>> if (test_bit(SOCK_PASSCRED, &sock->flags))
>> put_cmsg(msg, SOL_SOCKET, SCM_CREDENTIALS, sizeof(scm->creds), &scm->creds);
>>
>> + scm_destroy_cred(scm);
>> +
>> scm_passec(sock, msg, scm);
>>
>> if (!scm->fp)
>> diff --git a/net/core/scm.c b/net/core/scm.c
>> index b88f6f9..681c976 100644
>> --- a/net/core/scm.c
>> +++ b/net/core/scm.c
>> @@ -170,6 +170,30 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
>> err = scm_check_creds(&p->creds);
>> if (err)
>> goto error;
>> +
>
> I think this hunk needs to be documented. I.e. given that scm_send()
> will call scm_set_cred() before calling __scm_send, I don't see how
> these conditions could happen? If the condition can legitimately
> happen, then given all of the pid_t vs struct pid and 'cred' vs. 'creds'
> in these two hunks, I think a comment over each would be nice.
I think if you have the full context of __scm_send it becomes pretty obvious.
case SCM_CREDENTIALS:
if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct ucred)))
goto error;
memcpy(&p->creds, CMSG_DATA(cmsg), sizeof(struct ucred));
err = scm_check_creds(&p->creds);
if (err)
goto error;
At this point we have just copied ucred from userspace. We have done
scm_check_creds to ensure we allow the user to send the pid, uid, and
gid they have passed in.
These tests catch the case where the user is legitimately sending
something other than their own credentials.
>> + if (pid_vnr(p->pid) != p->creds.pid) {
>> + struct pid *pid;
>> + err = -ESRCH;
>> + pid = find_get_pid(p->creds.pid);
>> + if (!pid)
>> + goto error;
>> + put_pid(p->pid);
>> + p->pid = pid;
>> + }
>> +
>> + if ((p->cred->euid != p->creds.uid) ||
>> + (p->cred->egid != p->creds.gid)) {
>> + struct cred *cred;
>> + err = -ENOMEM;
>> + cred = prepare_creds();
>> + if (!cred)
>> + goto error;
>> +
>> + cred->uid = cred->euid = p->creds.uid;
>> + cred->gid = cred->egid = p->creds.uid;
>> + put_cred(p->cred);
>> + p->cred = cred;
>> + }
>> break;
>> default:
>> goto error;
Eric
^ permalink raw reply
* Re: [PATCH] net: Fix error in comment on net_device_ops::ndo_get_stats
From: David Miller @ 2010-06-15 22:10 UTC (permalink / raw)
To: bhutchings; +Cc: netdev, linux-net-drivers
In-Reply-To: <1276528781.2074.0.camel@achroite.uk.solarflarecom.com>
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Mon, 14 Jun 2010 16:19:41 +0100
> ndo_get_stats still returns struct net_device_stats *; there is
> no struct net_device_stats64.
>
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Applied.
But, I am ignoring every single patch you submit from here on
out that lacks a proper "net-2.6" or "net-next-2.6" destination
tree indication in your Subject line.
I've asked this of you at least 3 times, and you seem content to just
ignore my request. But that's OK, as I think you'll stop ignoring
me when it starts causing patches you care about to be dropped.
Thanks :-)
^ permalink raw reply
* Re: [PATCH] net: Fix error in comment on net_device_ops::ndo_get_stats
From: Ben Hutchings @ 2010-06-15 22:24 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-net-drivers
In-Reply-To: <20100615.151040.191416638.davem@davemloft.net>
On Tue, 2010-06-15 at 15:10 -0700, David Miller wrote:
> From: Ben Hutchings <bhutchings@solarflare.com>
> Date: Mon, 14 Jun 2010 16:19:41 +0100
>
> > ndo_get_stats still returns struct net_device_stats *; there is
> > no struct net_device_stats64.
> >
> > Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
>
> Applied.
>
> But, I am ignoring every single patch you submit from here on
> out that lacks a proper "net-2.6" or "net-next-2.6" destination
> tree indication in your Subject line.
>
> I've asked this of you at least 3 times, and you seem content to just
> ignore my request. But that's OK, as I think you'll stop ignoring
> me when it starts causing patches you care about to be dropped.
>
> Thanks :-)
Sorry Dave, I thought net-next-2.6 was still the default and I only
needed to make it more obvious when I wanted patches to go to net-2.6.
I've added the suffix to my git configuration now.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply
* Re: [PATCH 2/8] user_ns: Introduce user_nsmap_uid and user_ns_map_gid.
From: Eric W. Biederman @ 2010-06-15 22:37 UTC (permalink / raw)
To: Pavel Emelyanov
Cc: David Miller, Serge Hallyn, Linux Containers, Daniel Lezcano,
netdev
In-Reply-To: <4C173389.1010000@openvz.org>
Pavel Emelyanov <xemul@openvz.org> writes:
> On 06/13/2010 05:28 PM, Eric W. Biederman wrote:
>>
>> Define what happens when a we view a uid from one user_namespace
>> in another user_namepece.
>>
>> - If the user namespaces are the same no mapping is necessary.
>>
>> - For most cases of difference use overflowuid and overflowgid,
>> the uid and gid currently used for 16bit apis when we have a 32bit uid
>> that does fit in 16bits. Effectively the situation is the same,
>> we want to return a uid or gid that is not assigned to any user.
>>
>> - For the case when we happen to be mapping the uid or gid of the
>> creator of the target user namespace use uid 0 and gid as confusing
>> that user with root is not a problem.
>>
>> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
>
> I suppose this one should go via Andrew, not Dave.
If it was stand alone I would send it that way.
In this case I'm hope Dave will indulge me because this bit is
simple, the only user for now is the network stack, and the people
maintaining the code have already acked the patch.
Eric
^ permalink raw reply
* Re: [PATCH] drivers/staging/batman-adv: Use (pr|netdev)_<level> macro helpers
From: Joe Perches @ 2010-06-15 22:58 UTC (permalink / raw)
To: Sven Eckelmann, netdev
Cc: devel, Greg Kroah-Hartman,
b.a.t.m.a.n-ZwoEplunGu2X36UT3dwlltHuzzzSOjJt,
b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Simon Wunderlich,
Marek Lindner
In-Reply-To: <201006160037.48573.sven.eckelmann-Mmb7MZpHnFY@public.gmane.org>
On Wed, 2010-06-16 at 00:37 +0200, Sven Eckelmann wrote:
> Sven Eckelmann wrote:
Hi Sven.
> > The problem seems to be that dev_printk is used by netdev_printk (which is
> > used by netdev_info). netdev_printk will add (netdev)->dev.parent as second
> > parameter of dev_printk (and parent is NULL in our case). This macro will
> > now call dev_driver_string with NULL as parameter and just dereference
> > this null pointer.
> >
> > Maybe it is related to something else, but at least I think that this could
> > be the cause of the crash.
Nope, I think that's exactly correct.
> As far as I understand, the netdev_* stuff is made to be used by real drivers
> with more or less physical hardware. batman-adv is a virtual bridge used for
> mesh networks. Like net/bridge/ it has no physical parent device and only
> other net_devices are used inside of it - which may have real physical network
> devices as parents.
> Please correct me if my assumption is wrong.
No correction necessary...
netdev_printk and netdev_<level> are meant to be used
with parented network devices.
I think that netdev_<level> will eventually do the right
thing when dev->dev.parent is NULL. Right now, that'd
be a bit of an expensive test as it would be expanded in
place for every use of the macro.
Right now it's:
#define netdev_printk(level, netdev, format, args...) \
dev_printk(level, (netdev)->dev.parent, \
"%s: " format, \
netdev_name(netdev), ##args)
It could be something like:
#define netdev_printk(level, netdev, format, args...) \
do { \
if ((netdev)->dev.parent) \
dev_printk(level, (netdev)->dev.parent, \
"%s: " format, \
netdev_name(netdev), ##args); \
else \
printk(level "%s: " format, \
netdev_name(netdev), ##args); \
} while (0)
Unfortunately, that just about doubles the format string space,
so I don't really want to do that.
If/when %pV is accepted,
http://lkml.org/lkml/2010/3/4/17
http://lkml.org/lkml/2010/3/4/18
then the netdev_<level> macros will be converted to functions,
so size reduced with an added test for dev.parent == NULL without
the need to double the string space.
^ permalink raw reply
* Re: RX/close vcc race with solos/atmtcp/usbatm/he
From: Nathan Williams @ 2010-06-16 0:33 UTC (permalink / raw)
To: David Woodhouse; +Cc: linux-atm-general, netdev
In-Reply-To: <1275904970.17903.4658.camel@macbook.infradead.org>
On 7/06/2010 8:02 PM, David Woodhouse wrote:
> On Wed, 2010-05-26 at 12:16 +0100, David Woodhouse wrote:
>> I've had this crash reported to me...
>>
>> [18842.727906] EIP: [<e082f490>] br2684_push+0x19/0x234 [br2684]
>> SS:ESP 0068:dfb89d14
>
> Nathan, did you manage to get your customer to confirm that this fixes
> the problem? It'd be useful to get this into 2.6.35 and -stable.
>
No, I still haven't heard back from the customer. I'll keep sending email reminders.
^ permalink raw reply
* Re: [PATCH net-next-2.6] syncookies: check decoded options against sysctl settings
From: David Miller @ 2010-06-16 1:09 UTC (permalink / raw)
To: fw; +Cc: netdev
In-Reply-To: <1276464875-4460-1-git-send-email-fw@strlen.de>
From: Florian Westphal <fw@strlen.de>
Date: Sun, 13 Jun 2010 23:34:35 +0200
> - if (tcp_opt->sack_ok)
> - tcp_sack_reset(tcp_opt);
> + if (tcp_opt->sack_ok && !sysctl_tcp_sack)
> + return false;
>
If you remove the tcp_sack_reset() call here, who is going to
do it?
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox