📄 linux-kernel.diff
字号:
+ struct sockaddr md_nh;+};++int mpls_bogus_output(struct sk_buff *skb);+int mpls_set_nexthop(struct shim_blk* blk,struct dst_entry *dst);+int mpls_set_nexthop2(struct mpls_nhlfe *nhlfe, struct dst_entry *dst);+int mpls_output(struct sk_buff *skb); +int mpls_switch(struct sk_buff *skb); +int mpls_output_shim (struct sk_buff *skb, struct mpls_nhlfe *nhlfe);+int mpls_output2(struct sk_buff *skb,struct mpls_nhlfe *nhlfe);++/****************************************************************************+ * MPLS Destination (dst) Next hop (neighbour) cache management+ * net/mpls/mpls_dst.c+ ****************************************************************************/++int mpls_dst_init(void);+void mpls_dst_exit(void);+struct mpls_dst *mpls_dst_alloc(struct net_device *dev, struct sockaddr *nh);+void mpls_dst_release(struct mpls_dst *);+++/****************************************************************************+ * INPUT/OUTPUT INSTRUCTION OPCODES + * net/mpls/{mpls_opcode,mpls_opcode_in,mpls_opcode_out}.c+ *+ ****************************************************************************/+ +/*+ * skb: Socket buffer. May be modified [OUT] + * ilm: ILM entry object that owns this opcode. + * nhlfe: NHLF entry to apply. May be modified (e.g. MTU) [OUT] + * data: opcode dependant data. Cast to NHLFEs, DS marks, etc.+ */+#define MPLS_OPCODE_PROTOTYPE(NAME) \+int (NAME) (struct sk_buff** skb,struct mpls_ilm *ilm, \+ struct mpls_nhlfe **nhlfe, void *data) ++/*+ * instr: Instruction array. + * direction: MPLS_IN (ILM) or MPLS_OUT(NHLFE)+ * parent: ILM/NHLFE parent object for opcode.+ * data: opcode dependant data. [OUT]+ * last_able: Nonzero if this can be the last opcode. [OUT]+ * num_push: Number of pushes for this opcode. [OUT] (Incr. by OP_PUSH+ */+#define MPLS_BUILD_OPCODE_PROTOTYPE(NAME) \+int (NAME) (struct mpls_instr_elem *instr, \+ enum mpls_dir direction, void *parent,\+ void **data, int *last_able, int *num_push)++/*+ * instr: Instruction array. + * data: opcode dependant data. [OUT]+ */+#define MPLS_UNBUILD_OPCODE_PROTOTYPE(NAME) \+int (NAME) (struct mpls_instr_elem *instr, void *data)++/*+ * data: opcode dependant data.+ * parent: ILM/NHLFE parent object for opcode.+ * direction: MPLS_IN (ILM) or MPLS_OUT(NHLFE)+ */+#define MPLS_CLEAN_OPCODE_PROTOTYPE(NAME) \+void (NAME) (void *data, void *parent, enum mpls_dir direction)++/*+ * seq: seq_file output stream. + * data: opcode dependant data.+ * direction: MPLS_IN (ILM) or MPLS_OUT(NHLFE)+ */+#define MPLS_PRINT_OPCODE_PROTOTYPE(NAME) \+void (NAME) (struct seq_file *seq, void *data, enum mpls_dir direction)++#define MPLS_IN_OPCODE_PROTOTYPE(NAME) MPLS_OPCODE_PROTOTYPE(NAME) +#define MPLS_OUT_OPCODE_PROTOTYPE(NAME) MPLS_OPCODE_PROTOTYPE(NAME) ++struct mpls_ops {+ MPLS_IN_OPCODE_PROTOTYPE(*in);+ MPLS_OUT_OPCODE_PROTOTYPE(*out);+ MPLS_BUILD_OPCODE_PROTOTYPE(*build);+ MPLS_UNBUILD_OPCODE_PROTOTYPE(*unbuild);+ MPLS_CLEAN_OPCODE_PROTOTYPE(*cleanup);+ MPLS_PRINT_OPCODE_PROTOTYPE(*print);+ int extra;+ char *msg;+};++/* Array holding opcodes */+extern struct mpls_ops mpls_ops[];++void mpls_finish(struct sk_buff *skb);+int mpls_opcode_peek(struct sk_buff *skb);+int mpls_push(struct sk_buff **skb, struct mpls_label *label);+++/* Query/Update Incoming Labels */+int mpls_add_in_label (const struct mpls_in_label_req *in);+int mpls_get_in_label (struct mpls_in_label_req *in);+void __mpls_del_in_label (struct mpls_ilm *ilm);+int mpls_del_in_label (struct mpls_in_label_req *in);+int mpls_set_in_label_proto (struct mpls_in_label_req *in);+int mpls_add_reserved_label (int label, struct mpls_ilm* ilm);+struct mpls_ilm* mpls_del_reserved_label (int label);++/* Query/Update Outgoing Labels */+extern int mpls_add_out_label (struct mpls_out_label_req *out, int seq,+ int pid);+int mpls_get_out_label (struct mpls_out_label_req *out);+int mpls_del_out_label (struct mpls_out_label_req *out);+int mpls_set_out_label_mtu (struct mpls_out_label_req *out);++/* Query/Update Crossconnects */+int mpls_attach_in2out (struct mpls_xconnect_req *req);+int mpls_detach_in2out (struct mpls_xconnect_req *req);+int mpls_get_in2out (struct mpls_xconnect_req *req);++/* Instruction Management */+int mpls_set_in_label_instrs (struct mpls_instr_req *mir);+int mpls_set_out_label_instrs (struct mpls_instr_req *mir);+int mpls_set_in_instrs (struct mpls_instr_elem *mie, + int length, struct mpls_ilm *ilm);+int mpls_set_out_instrs (struct mpls_instr_elem *mie, + int length, struct mpls_nhlfe *nhlfe);+int mpls_set_out_label_propagate_ttl(struct mpls_out_label_req *mol);++void mpls_destroy_out_instrs (struct mpls_nhlfe *nhlfe);+void mpls_destroy_in_instrs (struct mpls_ilm *ilm);++/* Query/Update Labelspaces*/+int mpls_get_labelspace (struct mpls_labelspace_req *req);+int mpls_get_labelspace_by_name (const char *name);+int mpls_get_labelspace_by_index (int ifindex);+int mpls_set_labelspace (struct mpls_labelspace_req *req);+int mpls_set_labelspace_by_name (const char *name, int labelspace);+int mpls_set_labelspace_by_index (int ifindex, int labelspace);++/* Netlink event notification */+void mpls_ilm_event(int event, struct mpls_ilm *ilm);+void mpls_nhlfe_event(int event, struct mpls_nhlfe *nhlfe, int seq, int pid);+void mpls_labelspace_event(int event, struct net_device *dev);+void mpls_xc_event(int event, struct mpls_ilm *ilm,+ struct mpls_nhlfe *nhlfe);++/****************************************************************************+ * REFERENCE COUNT MANAGEMENT + ****************************************************************************/++/* Hold */+static inline struct mpls_ilm* mpls_ilm_hold(struct mpls_ilm* ilm)+{+ BUG_ON(!ilm);+ dst_hold (&ilm->u.dst);+ return ilm;+}+++/* Release */+static inline void mpls_ilm_release(struct mpls_ilm* ilm)+{+ BUG_ON(!ilm);+ dst_release(&ilm->u.dst);+}+++/* Hold */+static inline struct mpls_nhlfe* mpls_nhlfe_hold(struct mpls_nhlfe* nhlfe)+{+ BUG_ON(!nhlfe);+ atomic_inc(&nhlfe->__refcnt);+ return nhlfe;+}++/* Release */+static inline void mpls_nhlfe_release(struct mpls_nhlfe* nhlfe)+{+ BUG_ON(!nhlfe);+ atomic_dec(&nhlfe->__refcnt);+}++/****************************************************************************+ * SYSFS Implementation+ * net/mpls/mpls_sysfs.c+ ****************************************************************************/++int mpls_sysfs_init(void);+void mpls_sysfs_exit(void);++/****************************************************************************+ * ProcFS Implementation+ * net/mpls/mpls_procfs.c+ ****************************************************************************/++int mpls_procfs_init(void);+void mpls_procfs_exit(void);++/****************************************************************************+ * Shim Implementation+ * net/mpls/mpls_shim.c+ ****************************************************************************/++int mpls_shim_init(void);+void mpls_shim_exit(void);++/****************************************************************************+ * NetLink Implementation + * net/mpls/mpls_netlink.c+ ****************************************************************************/++extern struct rtnetlink_link mpls_rtnetlink_table[];+int mpls_netlink_init (void);+void mpls_netlink_exit (void);++/****************************************************************************+ * Virtual Intefaces (Tunnel) Management + * (e.g. mpls0, mpls1, TXXethN, etc.)+ * net/mpls/mpls_tunnel.c+ ****************************************************************************/++struct mpls_tunnel_private {+ /* NHLFE Object to apply to this tunnel traffic */+ struct mpls_nhlfe *mtp_nhlfe;+ /* Netdevice for this tunnel */+ struct net_device *mtp_dev;+ /* Next tunnel in list */+ struct mpls_tunnel_private *next;+ /* Netdevice (this tunnel) traffic stats */+ struct net_device_stats stat;+};+++struct net_device* mpls_tunnel_get_by_name (const char* name);+struct net_device* mpls_tunnel_get (struct mpls_tunnel_req *mt);+void mpls_tunnel_put (struct net_device *dev); +struct net_device* mpls_tunnel_create (struct mpls_tunnel_req *mt);+void mpls_tunnel_destroy (struct mpls_tunnel_req *mt); ++/* Casts */+#define _mpls_as_if(PTR) ((struct mpls_interface*)(PTR))+#define _mpls_as_label(PTR) ((struct mpls_label*)(PTR))+#define _mpls_as_ilm(PTR) ((struct mpls_ilm*)(PTR))+#define _mpls_as_nhlfe(PTR) ((struct mpls_nhlfe*)(PTR))+#define _mpls_as_dfi(PTR) ((struct mpls_dsmark_fwd_info*)(PTR))+#define _mpls_as_nfi(PTR) ((struct mpls_nfmark_fwd_info*)(PTR))+#define _mpls_as_efi(PTR) ((struct mpls_exp_fwd_info*)(PTR))+#define _mpls_as_netdev(PTR)((struct net_device*)(PTR))+#define _mpls_as_dst(PTR) ((struct mpls_dst*)(PTR))++#endifdiff -uNr linux-kernel/include/net/shim.h mpls-kernel-3/include/net/shim.h--- linux-kernel/include/net/shim.h 1969-12-31 18:00:00.000000000 -0600+++ mpls-kernel-3/include/net/shim.h 2005-10-09 23:16:00.000000000 -0500@@ -0,0 +1,48 @@+/*+ * Network shim interface for protocols that live below L3 but above L2+ *+ * This program is free software; you can redistribute it and/or+ * modify it under the terms of the GNU General Public License+ * as published by the Free Software Foundation; either version+ * 2 of the License, or (at your option) any later version.+ *+ * Authors: James R. Leu <jleu@mindspring.com>+ */+#ifndef _NET_SHIM_H+#define _NET_SHIM_H++#include <net/dst.h>+#include <linux/list.h>+#include <linux/shim.h>++struct shim_blk;++struct shim+{+ atomic_t __ref;+ struct list_head list;+ int (*build)(struct shim_blk *, struct dst_entry *);+ char name[SHIMNAMSIZ + 1];+};++struct shim_blk+{+ struct shim *shim;+ short datalen;+ char data[0];+};++extern void shim_proto_add(struct shim *spec);+extern int shim_proto_remove(struct shim *spec);+extern struct shim *shim_proto_find_by_name(const char* name);+extern struct shim_blk *shim_build_blk(struct rtshim* data);+extern void shim_destroy_blk(struct shim_blk* sblk);+extern int shim_blk_cmp(struct shim_blk* a, struct shim_blk* b);+extern int shim_rta_blk_cmp(struct rtshim* rta, struct shim_blk* sblk);+extern void shim_unbuild_blk(struct rtshim* data, struct shim_blk* sblk);+extern void shim_init(void);++#define shim_proto_release(V) atomic_dec((&V->__ref));+#define shim_proto_hold(V) atomic_inc((&V->__ref));++#endifdiff -uNr linux-kernel/net/bridge/Kconfig mpls-kernel-3/net/bridge/Kconfig--- linux-kernel/net/bridge/Kconfig 2005-09-19 22:47:52.000000000 -0500+++ mpls-kernel-3/net/bridge/Kconfig 2005-10-11 01:03:45.000000000 -0500@@ -29,3 +29,13 @@ will be called bridge. If unsure, say N.++config BRIDGE_MPLS+ tristate "Bridge: MPLS support"+ depends on BRIDGE && MPLS+ ---help---+ If you say Y here, the kernel will support being an egress for+ Ethernet over MPLS packets++ If unsure, say N.+diff -uNr linux-kernel/net/bridge/Makefile mpls-kernel-3/net/bridge/Makefile--- linux-kernel/net/bridge/Makefile 2004-07-23 12:29:23.000000000 -0500+++ mpls-kernel-3/net/bridge/Makefile 2005-11-07 23:38:49.000000000 -0600@@ -8,6 +8,7 @@ br_ioctl.o br_notify.o br_stp.o br_stp_bpdu.o \ br_stp_if.o br_stp_timer.o +obj-$(CONFIG_BRIDGE_MPLS) += mplsbr.o bridge-$(CONFIG_SYSFS) += br_sysfs_if.o br_sysfs_br.o bridge-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.odiff -uNr linux-kernel/net/bridge/mplsbr.c mpls-kernel-3/net/bridge/mplsbr.c--- linux-kernel/net/bridge/mplsbr.c 1969-12-31 18:00:00.000000000 -0600+++ mpls-kernel-3/net/bridge/mplsbr.c 2005-12-06 23:18:37.000000000 -0600@@ -0,0 +1,173 @@+/* mplsbr.c: ethernet over MPLS protocol driver.+ *+ * Copyright (C) 2005 James R. Leu (jleu@mindspring.com)+ */++#include <linux/module.h>+#include <linux/socket.h>+#include <linux/skbuff.h>+#include <linux/init.h>+#include <net/neighbour.h>+#include <net/dst.h>+#include <net/mpls.h>++MODULE_LICENSE("GPL");++static void dumb_neigh_destroy(struct neighbour *neigh)+{+}++static void dumb_neigh_solicit(struct neighbour *neigh,struct sk_buff *skb)+{+}++static void dumb_neigh_error(struct neighbour *neigh,struct sk_buff *skb)+{+ kfree_skb(skb);+}++static int dumb_neigh_dev_xmit(struct sk_buff *skb)+{+ skb->dev = skb->dst->dev;+ skb->ip_summed = CHECKSUM_NONE;+ dev_queue_xmit(skb);+ return 0;+}+++static struct neigh_ops dumb_neigh_ops = {+ .family = AF_PACKET,+ .destructor = dumb_neigh_destroy,+ .solicit = dumb_neigh_solicit,+ .error_report = dumb_neigh_error,+ .output = dumb_neigh_dev_xmit,+ .connected_output = dumb_neigh_dev_xmit,+ .hh_output = dumb_neigh_dev_xmit,+ .queue_xmit = dumb_neigh_dev_xmit,+};++static u32 dumb_neigh_hash(const void *pkey, const struct net_device *dev)+{+ return dev->ifindex;+}++static int dumb_neigh_constructor(struct neighbour *neigh)+{+ neigh->ops = &dumb_neigh_ops;+ neigh->output = neigh->ops->output;+ return 0;+}++static struct neigh_table dumb_tbl = {+ .family = AF_PACKET,+ .entry_size = sizeof(struct neighbour),+ .key_len = 4,+ .hash = dumb_neigh_hash,+ .constructor = dumb_neigh_constructor,+ .id = "dumb_neigh",++ /* parameters are copied from ARP ... */+ .parms = {+ .tbl = &dumb_tbl,+ .base_reachable_time = 30 * HZ,+ .retrans_time = 1 * HZ,+ .gc_staletime = 60 * HZ,+ .reachable_time = 30 * HZ,+ .delay_probe_time = 5 * HZ,+ .queue_len = 3,+ .ucast_probes = 3,+ .mcast_probes = 3,+ .anycast_delay = 1 * HZ,+ .proxy_delay = (8 * HZ) / 10,+ .proxy_qlen = 64,+ .locktime = 1 * HZ,+ },+ .gc_interval = 30 * HZ,+ .gc_thresh1 = 128,+ .gc_thresh2 = 512,+ .gc_thresh3 = 1024,+};++static void mplsbr_cache_flush(void)+{+}++static void mplsbr_set_ttl(struct sk_buff *skb, int ttl)+{+}++static int mplsbr_get_ttl(struct sk_buff *skb)+{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -