@@ -80,13 +80,17 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
80
80
bool exists = false;
81
81
int ret ;
82
82
83
- if (!nla )
83
+ if (!nla ) {
84
+ NL_SET_ERR_MSG_MOD (extack , "Mirred requires attributes to be passed" );
84
85
return - EINVAL ;
85
- ret = nla_parse_nested (tb , TCA_MIRRED_MAX , nla , mirred_policy , NULL );
86
+ }
87
+ ret = nla_parse_nested (tb , TCA_MIRRED_MAX , nla , mirred_policy , extack );
86
88
if (ret < 0 )
87
89
return ret ;
88
- if (!tb [TCA_MIRRED_PARMS ])
90
+ if (!tb [TCA_MIRRED_PARMS ]) {
91
+ NL_SET_ERR_MSG_MOD (extack , "Missing required mirred parameters" );
89
92
return - EINVAL ;
93
+ }
90
94
parm = nla_data (tb [TCA_MIRRED_PARMS ]);
91
95
92
96
exists = tcf_idr_check (tn , parm -> index , a , bind );
@@ -102,6 +106,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
102
106
default :
103
107
if (exists )
104
108
tcf_idr_release (* a , bind );
109
+ NL_SET_ERR_MSG_MOD (extack , "Unknown mirred option" );
105
110
return - EINVAL ;
106
111
}
107
112
if (parm -> ifindex ) {
@@ -117,8 +122,10 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
117
122
}
118
123
119
124
if (!exists ) {
120
- if (!dev )
125
+ if (!dev ) {
126
+ NL_SET_ERR_MSG_MOD (extack , "Specified device does not exist" );
121
127
return - EINVAL ;
128
+ }
122
129
ret = tcf_idr_create (tn , parm -> index , est , a ,
123
130
& act_mirred_ops , bind , true);
124
131
if (ret )
0 commit comments