Skip to contentSkip to conversation

linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option

PATCH Superseded Jing Huang 2 participants 2 messages Jul 20, 2012

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Jing Huang

author
#0 lore raw

PATCH v3 2/3 linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option

---
 linux-user/syscall.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
linux-user/syscall.c +19 -0
index 82aa83d..2228b1f 100644
@@ -60,6 +60,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
 #include <linux/wireless.h>
+#include <linux/icmp.h>
 #include "qemu-common.h"
 #ifdef TARGET_GPROF
 #include <sys/gmon.h>
@@ -1442,6 +1443,24 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
             goto unimplemented;
         }
         break;
+    case SOL_RAW:
+        switch (optname) {
+        case ICMP_FILTER:
+            /* struct icmp_filter takes an u32 value */
+            if (optlen < sizeof(uint32_t)) {
+                return -TARGET_EINVAL;
+            }
+
+            if (get_user_u32(val, optval_addr)) {
+                return -TARGET_EFAULT;
+            }
+            ret = get_errno(setsockopt(sockfd, level, optname,
+                                                &val, sizeof(val)));
+            break;
+        default:
+            goto unimplemented;
+        }
+        break;
     case TARGET_SOL_SOCKET:
         switch (optname) {
             /* Options with 'int' argument.  */
Signature · 1 line
1.7.8.6
Reviewed-by on v3 2/3
#1 lore raw
Quoted 2 lines · Jing Huang

(when you do the next version of this patch series, if you include that line in the commit message for this patch it will let me know I've already looked at this patch and don't need to read it again. You can keep the line as long as you don't make any further changes to the patch which would mean I have to re-review it.)

-- PMM