cregit-Linux how code gets into the kernel

Release 4.11 net/ipv6/netfilter/ip6t_mh.c

/*
 * Copyright (C)2006 USAGI/WIDE Project
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * Author:
 *      Masahide NAKAMURA @USAGI <masahide.nakamura.cz@hitachi.com>
 *
 * Based on net/netfilter/xt_tcpudp.c
 *
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/types.h>
#include <linux/module.h>
#include <net/ip.h>
#include <linux/ipv6.h>
#include <net/ipv6.h>
#include <net/mip6.h>

#include <linux/netfilter/x_tables.h>
#include <linux/netfilter_ipv6/ip6t_mh.h>

MODULE_DESCRIPTION("Xtables: IPv6 Mobility Header match");
MODULE_LICENSE("GPL");

/* Returns 1 if the type is matched by the range, 0 otherwise */

static inline bool type_match(u_int8_t min, u_int8_t max, u_int8_t type, bool invert) { return (type >= min && type <= max) ^ invert; }

Contributors

PersonTokensPropCommitsCommitProp
Masahide Nakamura2990.62%150.00%
Jan Engelhardt39.38%150.00%
Total32100.00%2100.00%


static bool mh_mt6(const struct sk_buff *skb, struct xt_action_param *par) { struct ip6_mh _mh; const struct ip6_mh *mh; const struct ip6t_mh *mhinfo = par->matchinfo; /* Must not be a fragment. */ if (par->fragoff != 0) return false; mh = skb_header_pointer(skb, par->thoff, sizeof(_mh), &_mh); if (mh == NULL) { /* We've been asked to examine this packet, and we can't. Hence, no choice but to drop. */ pr_debug("Dropping evil MH tinygram.\n"); par->hotdrop = true; return false; } if (mh->ip6mh_proto != IPPROTO_NONE) { pr_debug("Dropping invalid MH Payload Proto: %u\n", mh->ip6mh_proto); par->hotdrop = true; return false; } return type_match(mhinfo->types[0], mhinfo->types[1], mh->ip6mh_type, !!(mhinfo->invflags & IP6T_MH_INV_TYPE)); }

Contributors

PersonTokensPropCommitsCommitProp
Masahide Nakamura12280.79%222.22%
Jan Engelhardt2919.21%777.78%
Total151100.00%9100.00%


static int mh_mt6_check(const struct xt_mtchk_param *par) { const struct ip6t_mh *mhinfo = par->matchinfo; /* Must specify no unknown invflags */ return (mhinfo->invflags & ~IP6T_MH_INV_MASK) ? -EINVAL : 0; }

Contributors

PersonTokensPropCommitsCommitProp
Masahide Nakamura2771.05%120.00%
Jan Engelhardt1128.95%480.00%
Total38100.00%5100.00%

static struct xt_match mh_mt6_reg __read_mostly = { .name = "mh", .family = NFPROTO_IPV6, .checkentry = mh_mt6_check, .match = mh_mt6, .matchsize = sizeof(struct ip6t_mh), .proto = IPPROTO_MH, .me = THIS_MODULE, };
static int __init mh_mt6_init(void) { return xt_register_match(&mh_mt6_reg); }

Contributors

PersonTokensPropCommitsCommitProp
Masahide Nakamura1487.50%150.00%
Jan Engelhardt212.50%150.00%
Total16100.00%2100.00%


static void __exit mh_mt6_exit(void) { xt_unregister_match(&mh_mt6_reg); }

Contributors

PersonTokensPropCommitsCommitProp
Masahide Nakamura1386.67%150.00%
Jan Engelhardt213.33%150.00%
Total15100.00%2100.00%

module_init(mh_mt6_init); module_exit(mh_mt6_exit);

Overall Contributors

PersonTokensPropCommitsCommitProp
Masahide Nakamura29082.39%213.33%
Jan Engelhardt6117.33%1280.00%
Patrick McHardy10.28%16.67%
Total352100.00%15100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.