Make kernel version default to the latest one we support in the Makefile
authorSapan Bhatia <gwsapan@gmail.com>
Fri, 16 Aug 2013 20:59:32 +0000 (16:59 -0400)
committerSapan Bhatia <gwsapan@gmail.com>
Fri, 16 Aug 2013 20:59:32 +0000 (16:59 -0400)
Makefile
transforward.c

index 2965572..78b34dd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,15 @@
 obj-m += transforward.o
 
+KVER=$(shell uname -r)
+ARCH=$(shell uname -m)
+DIST=fc18 # Is there an easy way of fetching this automatically, short of mapping /etc/redhat-release
+
+ifeq ($(wildcard /lib/modules/$(KVER)/build),) 
+       KVER=3.10.6-100.$(DIST).$(KVER)
+endif
+
 all:
-       make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+       make -C /lib/modules/$(KVER)/build M=$(PWD) modules
 
 clean:
-       make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+       make -C /lib/modules/$(KVER)/build M=$(PWD) clean
index 13e6156..cd1b512 100644 (file)
@@ -41,7 +41,6 @@ MODULE_LICENSE("GPL");
 MODULE_VERSION(VERSION_STR);
 
 static int address_in_root(unsigned int haddr) {
-    //printk(KERN_CRIT "In address_in_root: %u",haddr);
     struct net_device *dev;
     struct net *net = &init_net;
 
@@ -56,6 +55,7 @@ static int address_in_root(unsigned int haddr) {
 static int inet_bind_entry(struct socket *sock, struct sockaddr *uaddr, int addr_len) {
     struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
     unsigned int snum = addr->sin_addr.s_addr;
+       //printk(KERN_CRIT "Checking address %d",snum);
     if (address_in_root(snum)) {
         put_net(sock_net(sock->sk));
         sock_net_set(sock->sk, get_net(&init_net));