Message ID | 1453451811-11860-4-git-send-email-zhang.zhanghailiang@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 01/22/2016 04:36 PM, zhanghailiang wrote: > If the filter is disabled, don't go through it. > > Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> > --- > include/net/filter.h | 5 +++++ > net/net.c | 4 ++++ > 2 files changed, 9 insertions(+) > > diff --git a/include/net/filter.h b/include/net/filter.h > index 9ed5ec6..d797ee4 100644 > --- a/include/net/filter.h > +++ b/include/net/filter.h > @@ -74,6 +74,11 @@ ssize_t qemu_netfilter_pass_to_next(NetClientState *sender, > int iovcnt, > void *opaque); > > +static inline bool qemu_need_skip_netfilter(NetFilterState *nf) > +{ > + return nf->enabled ? false : true; > +} > + > void netfilter_print_info(NetFilterState *nf, char *output_str, int size); > > #endif /* QEMU_NET_FILTER_H */ > diff --git a/net/net.c b/net/net.c > index 87de7c0..ec43105 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -581,6 +581,10 @@ static ssize_t filter_receive_iov(NetClientState *nc, > NetFilterState *nf = NULL; > > QTAILQ_FOREACH(nf, &nc->filters, next) { > + /* Don't go through filter if it is off */ > + if (qemu_need_skip_netfilter(nf)) { > + continue; > + } > ret = qemu_netfilter_receive(nf, direction, sender, flags, iov, > iovcnt, sent_cb); > if (ret) { > qemu_netfilter_pass_to_next() shoule also be updated. Thanks Wen Congyang
On 01/22/2016 05:32 PM, Wen Congyang wrote: > On 01/22/2016 04:36 PM, zhanghailiang wrote: >> If the filter is disabled, don't go through it. >> >> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >> --- >> include/net/filter.h | 5 +++++ >> net/net.c | 4 ++++ >> 2 files changed, 9 insertions(+) >> >> diff --git a/include/net/filter.h b/include/net/filter.h >> index 9ed5ec6..d797ee4 100644 >> --- a/include/net/filter.h >> +++ b/include/net/filter.h >> @@ -74,6 +74,11 @@ ssize_t qemu_netfilter_pass_to_next(NetClientState *sender, >> int iovcnt, >> void *opaque); >> >> +static inline bool qemu_need_skip_netfilter(NetFilterState *nf) >> +{ >> + return nf->enabled ? false : true; >> +} >> + >> void netfilter_print_info(NetFilterState *nf, char *output_str, int size); >> >> #endif /* QEMU_NET_FILTER_H */ >> diff --git a/net/net.c b/net/net.c >> index 87de7c0..ec43105 100644 >> --- a/net/net.c >> +++ b/net/net.c >> @@ -581,6 +581,10 @@ static ssize_t filter_receive_iov(NetClientState *nc, >> NetFilterState *nf = NULL; >> >> QTAILQ_FOREACH(nf, &nc->filters, next) { >> + /* Don't go through filter if it is off */ >> + if (qemu_need_skip_netfilter(nf)) { >> + continue; >> + } >> ret = qemu_netfilter_receive(nf, direction, sender, flags, iov, >> iovcnt, sent_cb); >> if (ret) { >> > qemu_netfilter_pass_to_next() shoule also be updated. Then let's better move it to qemu_netfiler_receive(). > > Thanks > Wen Congyang > > > >
On 2016/1/25 13:04, Jason Wang wrote: > > > On 01/22/2016 05:32 PM, Wen Congyang wrote: >> On 01/22/2016 04:36 PM, zhanghailiang wrote: >>> If the filter is disabled, don't go through it. >>> >>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> >>> --- >>> include/net/filter.h | 5 +++++ >>> net/net.c | 4 ++++ >>> 2 files changed, 9 insertions(+) >>> >>> diff --git a/include/net/filter.h b/include/net/filter.h >>> index 9ed5ec6..d797ee4 100644 >>> --- a/include/net/filter.h >>> +++ b/include/net/filter.h >>> @@ -74,6 +74,11 @@ ssize_t qemu_netfilter_pass_to_next(NetClientState *sender, >>> int iovcnt, >>> void *opaque); >>> >>> +static inline bool qemu_need_skip_netfilter(NetFilterState *nf) >>> +{ >>> + return nf->enabled ? false : true; >>> +} >>> + >>> void netfilter_print_info(NetFilterState *nf, char *output_str, int size); >>> >>> #endif /* QEMU_NET_FILTER_H */ >>> diff --git a/net/net.c b/net/net.c >>> index 87de7c0..ec43105 100644 >>> --- a/net/net.c >>> +++ b/net/net.c >>> @@ -581,6 +581,10 @@ static ssize_t filter_receive_iov(NetClientState *nc, >>> NetFilterState *nf = NULL; >>> >>> QTAILQ_FOREACH(nf, &nc->filters, next) { >>> + /* Don't go through filter if it is off */ >>> + if (qemu_need_skip_netfilter(nf)) { >>> + continue; >>> + } >>> ret = qemu_netfilter_receive(nf, direction, sender, flags, iov, >>> iovcnt, sent_cb); >>> if (ret) { >>> >> qemu_netfilter_pass_to_next() shoule also be updated. > > Then let's better move it to qemu_netfiler_receive(). > Good idea, i will fix it, thanks. >> >> Thanks >> Wen Congyang >> >> >> >> > > > . >
diff --git a/include/net/filter.h b/include/net/filter.h index 9ed5ec6..d797ee4 100644 --- a/include/net/filter.h +++ b/include/net/filter.h @@ -74,6 +74,11 @@ ssize_t qemu_netfilter_pass_to_next(NetClientState *sender, int iovcnt, void *opaque); +static inline bool qemu_need_skip_netfilter(NetFilterState *nf) +{ + return nf->enabled ? false : true; +} + void netfilter_print_info(NetFilterState *nf, char *output_str, int size); #endif /* QEMU_NET_FILTER_H */ diff --git a/net/net.c b/net/net.c index 87de7c0..ec43105 100644 --- a/net/net.c +++ b/net/net.c @@ -581,6 +581,10 @@ static ssize_t filter_receive_iov(NetClientState *nc, NetFilterState *nf = NULL; QTAILQ_FOREACH(nf, &nc->filters, next) { + /* Don't go through filter if it is off */ + if (qemu_need_skip_netfilter(nf)) { + continue; + } ret = qemu_netfilter_receive(nf, direction, sender, flags, iov, iovcnt, sent_cb); if (ret) {
If the filter is disabled, don't go through it. Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> --- include/net/filter.h | 5 +++++ net/net.c | 4 ++++ 2 files changed, 9 insertions(+)