RE: IPV6 related constants for netlink socket

2012-10-31 Thread Murali Annamneni
Hi,

I'm trying to create a Netlink socket to configure an ipv6 interface.
The socket call I used is -

socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE6);

I'm getting compiler error error: NETLINK_ROUTE6 undeclared (first use in this 
function)
And I'm facing the same problem for AF_NETLINK6.

I grep'ed in source code of 2.6.32 kernel and system header files, I didn't 
find anywhere these constants.
Are these constants are correct ? If not, what are the correct one's and in 
which header file I can find them.

Thanks  Regards
Murali Annamneni



::DISCLAIMER::


The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information 
could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in 
transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on 
the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the 
author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, 
dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written 
consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please 
delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and 
other defects.


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Tools for checking incorrect usage of locking techniques in k-space

2012-10-31 Thread Kumar amit mehta
On Mon, Oct 29, 2012 at 12:03:08AM +0530, Srivatsa Bhat wrote:
 You'll need CONFIG_LOCKDEP=y as well. An easy way to configure lock debugging
 checks is to run 'make menuconfig' and enable the required options under the
 Kernel hacking section.
 
 
  If above configuration is all that I need, then should I be seeing 
  warning/error
  messages in kernel logs(/var/log/kern.log) when there is inconsistency in
  locking ? To test my hypothesis, I modified my simple kernel module to
  deliberately induce locking error (After initializing read-write semaphore, 
  I call
  down_write() and do not free this semaphore lock by commenting out 
  up_write()
  invocation). But still I don't see any error or warning message trace in 
  kernel
  logs, I think, I'm missing something.

Hi Srivatsa,

Thank you for your mail. As per your suggestion, this time I've enabled
CONFIG_LOCKDEP aslo in my running kernel and did the same experiment, but still 
I dont't see any warning/error messages in the kernel log. To give you more idea
about what I'm doing, Please see the code below.(This is a simple char driver
based on LDD3 examples)

echo.c

#include linux/module.h
#include linux/init.h
#include linux/types.h //MAJOR, MINOR
#include linux/fs.h //register_chrdev_region, file_operations
#include linux/moduleparam.h
#include linux/kernel.h //container_of
#include linux/slab.h //kmalloc
#include linux/cdev.h //struct cdev
#include linux/version.h
#include linux/uaccess.h //copy_from/to_user()
#include linux/errno.h //error code

ssize_t echo_read(struct file *, char __user *, size_t, loff_t *);
ssize_t echo_write(struct file *, const char __user *, size_t, loff_t *);
int echo_open(struct inode *, struct file *);
int echo_release(struct inode *, struct file *);

struct echo_cdev {
char *data;
unsigned long size; //amount of data stored
struct semaphore sem;
struct cdev cdev;
};
MODULE_LICENSE(GPL v2);
MODULE_AUTHOR(amit);

int nr_major;
module_param(nr_major, int, S_IRUGO);
MODULE_PARM_DESC(nr_major, major number);

int nr_minor;
char *chrdev_name = echo;

static dev_t device;
static int echo_dev_count = 1;
struct echo_cdev *echo_dev = NULL;

static struct file_operations echo_fs_ops = {
.open = echo_open,
.release = echo_release,
.read = echo_read,
.write = echo_write,
.owner = THIS_MODULE,
};

int echo_open(struct inode *inode, struct file *filp)
{
struct echo_cdev *dev;
pr_debug(%s: f_flags: 0x%x\n,__FUNCTION__,filp-f_flags);
//container_of(pointer, container_type, container_field);
dev = container_of(inode-i_cdev, struct echo_cdev, cdev);
filp-private_data = dev;
if ((filp-f_flags  O_ACCMODE) == O_WRONLY) {
//trim the device size to 0
dev-size = 0;
}
return 0;
}

int echo_release(struct inode *inode, struct file *filp)
{
return 0;
}

ssize_t echo_read(struct file *filp, char __user *ubuff, size_t count, loff_t 
*poffset)
{
struct echo_cdev *dev = filp-private_data;
pr_debug(%s: f_flags: 0x%x\n,__FUNCTION__,filp-f_flags);

//user trying to access an offset which is beyond the end of file 
if (down_interruptible(dev-sem)) 
return -ERESTARTSYS;
if (*poffset = dev-size) {
up(dev-sem);
return 0;
}

//user trying to access more than eof, return bytes read till the eof
if (*poffset + count = dev-size) 
//count = dev-size - *poffset;
count = dev-size;
//kspace -- uspace
if (copy_to_user(ubuff, (dev-data + *poffset), count)  0) {
up(dev-sem);
return -EFAULT;
}
//update the offset
*poffset += count;
up(dev-sem);
return count;
}

//count is the size of requested data transfer
ssize_t echo_write(struct file *filp, const char __user *ubuff, size_t count, 
loff_t *poffset)
{
int ret;
struct echo_cdev *dev = filp-private_data;
pr_debug(%s: f_flags: 0x%x\n,__FUNCTION__,filp-f_flags);
if (down_interruptible(dev-sem)) 
return -ERESTARTSYS;
if (dev-data == NULL) {
dev-data = (char *)kmalloc(count, GFP_KERNEL);
if (!dev-data) {
up(dev-sem);
return -ENOMEM;
} else {
memset(dev-data, 0, sizeof(count));
}
}
dev-size = count;
//uspace -- kspace
if (copy_from_user(dev-data, ubuff, count)  0) {
up(dev-sem);
return -EFAULT;
}

*poffset += count;
ret = count;

if (dev-size  *poffset)
dev-size = *poffset;
//Force lock error
//up(dev-sem);
return ret;
}

static int __init echo_init(void)
{
int ret;

IPV6 related constants for netlink socket

2012-10-31 Thread Murali Annamneni
Hi,

I'm trying to create a Netlink socket to configure an ipv6 interface.
The socket call I used is -

socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE6);

I'm getting compiler error error: NETLINK_ROUTE6 undeclared (first use in this 
function)
And I'm facing the same problem for AF_NETLINK6.

I grep'ed in source code of 2.6.32 kernel and system header files, I didn't 
find anywhere these constants.
Are these constants are correct ? If not, what are the correct one's and in 
which header file I can find them.

Thanks  Regards
Murali Annamneni



::DISCLAIMER::


The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information 
could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in 
transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on 
the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the 
author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, 
dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written 
consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please 
delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and 
other defects.


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: linux segment

2012-10-31 Thread Mulyadi Santosa
On Tue, Oct 30, 2012 at 7:44 AM, Fan Yang lljyang...@gmail.com wrote:
 Hi  Mulyadi Santosa
I get the same result during the kernel module init and exit. Then I try
 to add a syscall to print these registers, and nothing changed. It is
 strange.

I think you need to observe deeper, something change this.

BTW, are you running this inside a virtualization? and which kernel
version do you use?

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: IPV6 related constants for netlink socket

2012-10-31 Thread Kristof Provost
On 2012-10-31 15:20:58 (+0530), Murali Annamneni a.mur...@hcl.com wrote:
 I'm trying to create a Netlink socket to configure an ipv6 interface.
 The socket call I used is -
 
 socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE6);
 
 I'm getting compiler error error: NETLINK_ROUTE6 undeclared (first use in 
 this function)
 And I'm facing the same problem for AF_NETLINK6.
 
That'd be because NETLINK_ROUTE6 and AF_NETLINK6 don't actually exist.

 I grep'ed in source code of 2.6.32 kernel and system header files, I
 didn't find anywhere these constants.  Are these constants are correct
 ? If not, what are the correct one's and in which header file I can
 find them.

Take a look at rtnetlink_rcv_msg() in net/core/rtnetlink.c
One of the things it extracts from the netlink message is the family. In
other words, you need to create a plain NETLINK_ROUTE socket, and
specify the family in the message itself. You can use the same socket
for both IPv4 and IPv6.

(My comments reflect the current kernel, but they're probably also valid
for 2.6.32)

Regards,
Kristof

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies