@@ -700,6 +700,27 @@ H_argo_notify(xen_argo_ring_data_t *rd)
700700 return HYPERVISOR_argo_op (XEN_ARGO_OP_notify , rd , NULL , 0 , 0 );
701701}
702702
703+ static int
704+ H_viptables_add (xen_argo_viptables_rule_t * rule , int position )
705+ {
706+ return HYPERVISOR_argo_op (XEN_ARGO_OP_viptables_add , rule , NULL , 0 ,
707+ position );
708+ }
709+
710+ static int
711+ H_viptables_del (xen_argo_viptables_rule_t * rule , int position )
712+ {
713+ return HYPERVISOR_argo_op (XEN_ARGO_OP_viptables_del , rule , NULL , 0 ,
714+ position );
715+ }
716+
717+ static int
718+ H_viptables_list (xen_argo_viptables_list_t * rules_list )
719+ {
720+ return HYPERVISOR_argo_op (XEN_ARGO_OP_viptables_list , rules_list , NULL , 0 ,
721+ 0 );
722+ }
723+
703724/*********************port/ring uniqueness **********/
704725
705726/*Need to hold write lock for all of these*/
@@ -1539,6 +1560,28 @@ argo_notify(void)
15391560 DEBUG_APPLE ;
15401561}
15411562
1563+ /*********************** viptables ********************/
1564+ static int
1565+ viptables_add (struct argo_private * p , struct xen_argo_viptables_rule * rule ,
1566+ int position )
1567+ {
1568+ return H_viptables_add (rule , position );
1569+ }
1570+
1571+ static int
1572+ viptables_del (struct argo_private * p , struct xen_argo_viptables_rule * rule ,
1573+ int position )
1574+ {
1575+ return H_viptables_del (rule , position );
1576+ }
1577+
1578+ static int
1579+ viptables_list (struct argo_private * p ,
1580+ struct xen_argo_viptables_list * rules_list )
1581+ {
1582+ return H_viptables_list (rules_list );
1583+ }
1584+
15421585/*********************** state machines ********************/
15431586static int
15441587connector_state_machine (struct argo_private * p , struct argo_stream_header * sh )
@@ -3035,8 +3078,8 @@ static int
30353078allocate_fd_with_private (void * private )
30363079{
30373080 int fd ;
3081+ const char * name = "" ;
30383082 struct file * f ;
3039- struct qstr name = { .name = "" };
30403083 struct path path ;
30413084 struct inode * ind ;
30423085
@@ -3048,34 +3091,42 @@ allocate_fd_with_private (void *private)
30483091 if ( fd < 0 )
30493092 return fd ;
30503093
3094+ #if ( LINUX_VERSION_CODE < KERNEL_VERSION (4 ,19 ,0 ) )
30513095 path .dentry = d_alloc_pseudo (argo_mnt -> mnt_sb , & name );
3052- if ( unlikely (!path .dentry ) )
3053- {
3096+ if (unlikely (!path .dentry )) {
30543097 put_unused_fd (fd );
3055- return - ENOMEM ;
3098+ return - ENOMEM ;
30563099 }
3100+ #endif
3101+
30573102 ind = new_inode (argo_mnt -> mnt_sb );
30583103 ind -> i_ino = get_next_ino ();
30593104 ind -> i_fop = argo_mnt -> mnt_root -> d_inode -> i_fop ;
30603105 ind -> i_state = argo_mnt -> mnt_root -> d_inode -> i_state ;
30613106 ind -> i_mode = argo_mnt -> mnt_root -> d_inode -> i_mode ;
30623107 ind -> i_uid = current_fsuid ();
30633108 ind -> i_gid = current_fsgid ();
3109+ #if ( LINUX_VERSION_CODE < KERNEL_VERSION (4 ,19 ,0 ) )
30643110 d_instantiate (path .dentry , ind );
3065-
30663111 path .mnt = mntget (argo_mnt );
3112+ #endif
30673113
30683114 DEBUG_APPLE ;
3115+ #if ( LINUX_VERSION_CODE < KERNEL_VERSION (4 ,19 ,0 ) )
30693116 f = alloc_file (& path , FMODE_READ | FMODE_WRITE , & argo_fops_stream );
3117+ #else
3118+ f = alloc_file_pseudo (ind , argo_mnt , name , O_RDWR , & argo_fops_stream );
3119+ #endif
30703120 if ( !f )
30713121 {
30723122 //FIXME putback fd?
30733123 return - ENFILE ;
30743124 }
30753125
30763126 f -> private_data = private ;
3127+ #if ( LINUX_VERSION_CODE < KERNEL_VERSION (4 ,19 ,0 ) )
30773128 f -> f_flags = O_RDWR ;
3078-
3129+ #endif
30793130 fd_install (fd , f );
30803131
30813132 return fd ;
@@ -3818,6 +3869,65 @@ argo_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
38183869 rc = argo_recvfrom (p , a .buf , a .len , a .flags , NULL , nonblock );
38193870 }
38203871 break ;
3872+ case ARGOIOCVIPTABLESADD :
3873+ DEBUG_APPLE ;
3874+ {
3875+ struct viptables_rule_pos rule_pos ;
3876+ struct xen_argo_viptables_rule rule ;
3877+
3878+ if ( copy_from_user (& rule_pos , (void __user * )arg ,
3879+ sizeof (struct viptables_rule_pos )) ||
3880+ copy_from_user (& rule , rule_pos .rule ,
3881+ sizeof (struct xen_argo_viptables_rule )) )
3882+ return - EFAULT ;
3883+
3884+ rc = viptables_add (p , & rule , rule_pos .position );
3885+ }
3886+ break ;
3887+ case ARGOIOCVIPTABLESDEL :
3888+ DEBUG_APPLE ;
3889+ {
3890+ struct viptables_rule_pos rule_pos ;
3891+ struct xen_argo_viptables_rule rule ;
3892+
3893+ if ( copy_from_user (& rule_pos , (void __user * )arg ,
3894+ sizeof (struct viptables_rule_pos )) )
3895+ return - EFAULT ;
3896+
3897+ if ( rule_pos .rule )
3898+ {
3899+ if ( copy_from_user (& rule , rule_pos .rule ,
3900+ sizeof (struct xen_argo_viptables_rule )) )
3901+ return - EFAULT ;
3902+
3903+ rc = viptables_del (p , & rule , rule_pos .position );
3904+ }
3905+ else
3906+ rc = viptables_del (p , NULL , rule_pos .position );
3907+ }
3908+ break ;
3909+ case ARGOIOCVIPTABLESLIST :
3910+ DEBUG_APPLE ;
3911+ {
3912+ struct xen_argo_viptables_list rules_list ;
3913+
3914+ if ( !access_ok (VERIFY_WRITE , (void __user * )arg ,
3915+ sizeof (struct xen_argo_viptables_list )) )
3916+ return - EFAULT ;
3917+
3918+ if ( get_user (rules_list .nrules ,
3919+ & ((struct xen_argo_viptables_list * )arg )-> nrules ) )
3920+ return - EFAULT ;
3921+
3922+ rc = viptables_list (p , & rules_list );
3923+ if ( rc )
3924+ return rc ;
3925+
3926+ if ( copy_to_user ((void __user * )arg , & rules_list ,
3927+ sizeof (struct xen_argo_viptables_list )) )
3928+ return - EFAULT ;
3929+ }
3930+ break ;
38213931 default :
38223932 printk (KERN_ERR "unknown ioctl: cmd=%x ARGOIOCACCEPT=%lx\n" , cmd ,
38233933 ARGOIOCACCEPT );
0 commit comments